Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2010, 01:13 PM   PM User | #1
needsomehelp
Regular Coder

 
Join Date: Oct 2009
Posts: 302
Thanks: 4
Thanked 3 Times in 3 Posts
needsomehelp can only hope to improve
mysql_fetch_array() not working for some reason

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.



Code:
$result=mysql_query("SELECT * FROM `table` WHERE `field`='" . $info. "' LIMIT 1");
	$row=mysql_fetch_array($result);
	$n[0]=$row[field1];
	$e[0]=$row[field2];
needsomehelp is offline   Reply With Quote
Old 02-21-2010, 03:03 PM   PM User | #2
Killermud
Regular Coder

 
Join Date: Mar 2009
Location: United Kingdom
Posts: 161
Thanks: 6
Thanked 28 Times in 28 Posts
Killermud is on a distinguished road
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 :

PHP Code:
$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!
Killermud is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:51 PM.


Advertisement
Log in to turn off these ads.