Re: [PHP] Undefined variable problem
* Thus wrote Ryan A ([EMAIL PROTECTED]): > > Notice: Undefined variable: email1 in c:\phpdev\www\bwh\project\compare.php > on line 117 > [...] > >$m = 1; >while ($line = mysql_fetch_assoc($rs)) { //dumping into an array > foreach ($line as $field => $value) { > $tmp = $field.$m; > $$tmp.= $value; /* This is the error line 117*** */ Your concating a variable that doesnt exist. Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined variable problem
IT WORKS!!! Thanks for replying and the solution. Cheers, -Ryan Hello, This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at 14:47, lines prefixed by '>' were originally written by you. > Notice: Undefined variable: email1 in > c:phpdevwwwbwhprojectcompare.php > on line 117 > $$tmp.= $value; /* This is the error line 117*** */ You are trying to append to the variable instead of create it, change this line to: $$tmp = $value; David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) We will slaughter you all! - The Iraqi (Dis)information ministers site http://MrSahaf.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined variable problem
Hello This is the code: $m = 1; while ($line = mysql_fetch_assoc($rs)) { //dumping into an array foreach ($line as $field => $value) { $tmp = $field.$m; $$tmp.= $value; /* This is the error line 117*** */ } $m++; } This is basically so that i can use the array via variables like so: if($tcl2==1){echo $tcl2;} instead of: if($arrayname['tcl']['1']==1){echo $arrayname['tcl']['1'];} and so onesp since i have 38 fields. I can of course just shut off error reporting...but thats not the best solution right? and i still wouldnt know whats causing these notices... Simply define $$tmp -variable before adding stuff in it. [code] $m = 1; while ($line = mysql_fetch_assoc($rs)) { //dumping into an array foreach ($line as $field => $value) { $tmp = $field.$m; $$tmp = ""; $$tmp .= $value; } $m++; } [/code] No it should whine about undefined vars. Cheers, Joona -- Joona Kulmala <[EMAIL PROTECTED]> PHP Finland -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined variable problem
Hello, This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at 14:47, lines prefixed by '>' were originally written by you. > Notice: Undefined variable: email1 in > c:phpdevwwwbwhprojectcompare.php > on line 117 > $$tmp.= $value; /* This is the error line 117*** */ You are trying to append to the variable instead of create it, change this line to: $$tmp = $value; David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php