What Does This Error Means???

Discussion in 'PHP' started by Midwest, May 4, 2008.

  1. #1
    While installing my arcade I got this error:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fooromco/public_html/config.php on line 20

    what does it means ???
     
    Midwest, May 4, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    It means that the mysql query was not executed properly. Check if the SQL statement has correct syntax.
    Tip:
    add " or die(mysql_error());" to the end of the query. It will spell out an more meaningful error.
    eg euage
    
    $resource=mysql_query($sql) or die(mysql_error());
    
    PHP:
     
    rohan_shenoy, May 4, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    It means that the query was invalid.

    Sometimes is something as small as mis-spelling (values,insert,into,update) or quotation (').

    Peace,
     
    Barti1987, May 4, 2008 IP
  4. vishnups

    vishnups Banned

    Messages:
    166
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here's what's going on with 'not a valid result resource' errors. Take the following example:
    
    $query = 'SELECT * from table';
       
       $result = mysql_query($query);
       
       while($row = mysql_fetch_array($result))
       { echo $row['foo']; }
    
    Code (markup):
    In the above, the mysql_query() function is sending the specific query to the database and returning a 'resource identifier', which is being set as the value of $result. These are not the results themselves -- if you echo $result at this point, you'll get 'Resource id #x'. The mysql_fetch_array() function in your while loop takes this resource identifier and creates an array of the actual db contents that you can use.

    If your mysql_query() function fails to get a resource id, it returns a boolean FALSE instead. FALSE, of course, isn't a resource identifier, so when you try to pass it to mysql_fetch_array(), it will cough up the 'not a valid result resource' error. So all of you are getting failures in your mysql_query() function.

    Using 'or die(mysql_error())' at the end of your mysql_query() call, will, instead of setting $result to FALSE, kill the script and, more importantly, return a more descriptive error message.

    Probably 80%+ of the time, a failed mysql_query() is caused by a syntax error in the query itself. Be especially mindful of any variables you're using in your query -- if they're not being set correctly, they can cause a syntax error. A failure to connect to the database can also cause mysql_query() to fail, so keep that in mind. Either way, the mysql_error() function will give you more information.

    Check your config.PhP file...
     
    vishnups, May 5, 2008 IP