Triple_Nothing Posted January 24, 2011 Share Posted January 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225501-mysql_fetch_row-expects-parameter-1-to-be-resource-boolean-given/ Share on other sites More sharing options...
Triple_Nothing Posted January 24, 2011 Author Share Posted January 24, 2011 Wow am I blonde. Must be the morning hours... I forgot to tell it which table to select from. Heh. Quote Link to comment https://forums.phpfreaks.com/topic/225501-mysql_fetch_row-expects-parameter-1-to-be-resource-boolean-given/#findComment-1164419 Share on other sites More sharing options...
PFMaBiSmAd Posted January 24, 2011 Share Posted January 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225501-mysql_fetch_row-expects-parameter-1-to-be-resource-boolean-given/#findComment-1164421 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.