Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    430
    Thanks
    6
    Thanked 3 Times in 3 Posts

    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];

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •