...

View Full Version : mysql_fetch_array() not working for some reason



needsomehelp
02-21-2010, 02:13 PM
I am unable to figure out why i can not get the results to go in an array.
this is what code i originally had in my code but now it does not work where it did a few years ago.

seems my code is out of date

can anyone advise what i should do to update it so it is working again.





$result=mysql_query("SELECT * FROM `table` WHERE `field`='" . $info. "' LIMIT 1");
$row=mysql_fetch_array($result);
$n[0]=$row[field1];
$e[0]=$row[field2];

Killermud
02-21-2010, 04:03 PM
There could be multiple reasons, first what springs to mind is the use of `` only use them if nothing else works and only for columns at that as SQL is probably getting confused with selecting from a column. So heres what i would do :


$result=mysql_query("SELECT * FROM table WHERE field='$info' LIMIT 1") or die(mysql_error());
$row=mysql_fetch_array($result);
$n[0]=$row[field1];
$e[0]=$row[field2];

This should work if not it will give us an error telling us what is wrong.

Hope this helps!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum