php - mysql class instance not recognized -


i trying figure out ancient php sql code having write text file instead of editing sql database. for loop giving me major issues though. doesn't return anything! think has curly bracket variable ${$currid}.

the $ids variable array of gages pulled website works fine because can echo $ids[$i]; , returns number of gage.

oh yeah, , parts commented out original parts of code i've ommited avoid editing sql database. thought might important include them.

$file = fopen("test.txt","w"); $intizzler = count($ids);  for($i=0; $i<$intizzler; $i++){ //echo ($i+1) . " / " . $intizzler . ":"; $currid = $ids[$i]; ${$currid} = new gage($currid);  //mysql_query("insert gage     //(id,lng,lat,title,text,pic,datum,coords,county)values(     echo fwrite($file,${$currid}->getfield('id'));     echo fwrite($file,${$currid}->getfield('long'));     echo fwrite($file,${$currid}->getfield('lat'));     echo fwrite($file,${$currid}->getfield('title'));     echo fwrite($file,${$currid}->getfield('text'));     echo fwrite($file,${$currid}->getfield('pic'));     echo fwrite($file,${$currid}->getfield('datum'));     echo fwrite($file,${$currid}->getfield('coords'));     echo fwrite($file,${$currid}->getfield('county'));     //)") or die(mysql_error());  //echo "write complete $currid <br/>"; } 

i'm stumped. appreciated.

as stated in comments when using variable variables variable still has resolve valid variable name. try instead:

<?php  $file = fopen("test.txt","w"); $intizzler = count($ids);  for($i=0; $i<$intizzler; $i++){ //echo ($i+1) . " / " . $intizzler . ":"; $currid = $ids[$i]; $gage = new gage($currid);  //mysql_query("insert gage     //(id,lng,lat,title,text,pic,datum,coords,county)values(     echo fwrite($file,$gage->getfield('id'));     echo fwrite($file,$gage->getfield('long'));     echo fwrite($file,$gage->getfield('lat'));     echo fwrite($file,$gage->getfield('title'));     echo fwrite($file,$gage->getfield('text'));     echo fwrite($file,$gage->getfield('pic'));     echo fwrite($file,$gage->getfield('datum'));     echo fwrite($file,$gage->getfield('coords'));     echo fwrite($file,$gage->getfield('county'));     //)") or die(mysql_error());  //echo "write complete $currid <br/>"; } 

Comments