Jump to content

mysql_fetch_row() expects parameter 1 to be resource, boolean given


Recommended Posts

Howdy y'all. I'm rather good at troubleshooting my errors, especially when I know what the error means. That way I at least have an idea of what I am looking for. This one has me at a loss...

Error:

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in ...

And the area it references is:

$carrier = mysql_fetch_row(mysql_query("SELECT `CarrierName` WHERE `CarrierID` = " . $myArray[$i][6]));

The $myArray[$i][6] holds a single digit number for a value.

The error means that the query failed due to an error. It does not mean that the query matched zero rows. One of the possible errors would be a sql syntax error if $myArray[$i][6] is empty or non-existent.

 

You should form your query string in a variable, such as $query, and then echo the query so that you can see what it actually contains.

 

You should not nest mysql_fetch_row(mysql_query()) functions as that prevents you from testing if the query executed without errors before you attempt to fetch data from a non-existent result resource (a query that matches zero rows returns a result resource that contains zero rows.) You would then also be able to use mysql_num_rows() to determine how many rows the query returns when it actually executes without errors.

 

Edit: Using some error checking and error reporting logic on the query, would have pointed out where in the query to look.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.