Re: Undefined variable problem
| From: | Joona Kulmala | Date: | Fri, 01 Aug 2003 14:01:36 +0000 |
| Subject: | Re: Undefined variable problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157934@lists.php.net to get a copy of this message | ||
Hello
This is the code: $m = 1; while ($line = mysql_fetch_assoc($rs)) { //dumping into an arraySimply define $$tmp -variable before adding stuff in it. [code] $m = 1; while ($line = mysql_fetch_assoc($rs)) { //dumping into an arrayforeach ($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 on....esp 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...
foreach ($line as $field => $value) {
$tmp = $field.$m;
$$tmp = "";
$$tmp .= $value; }
$m++;
}
[/code]
No it should whine about undefined vars.
Cheers, Joona
--
Joona Kulmala <joona@fiveam.org>
PHP Finland