mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

You need to check the return value of mysql_query

$query = 'YOUR QUERY';
$result = mysql_query($query);
if (!$result) {
    trigger_error('Invalid query: ' . mysql_error()." in ".$query);
}
// go ahead and fetch the results using mysql_num_rows.

If mysql_query fails it returns boolean false instead of a resource.

When you pass this boolean value to mysql_num_rows you get this error.

Leave a Comment