How can the "mysql_num_rows() expects parameter 1 to be resource, boolean given" error be resolved in PHP?
The error "mysql_num_rows() expects parameter 1 to be resource, boolean given" occurs when the query execution fails and returns a boolean value (false) instead of a resource. To resolve this issue, you should check if the query execution was successful before calling mysql_num_rows().
// Check if the query execution was successful
$result = mysql_query($query);
if($result === false) {
die("Error in query execution: " . mysql_error());
}
// Now you can safely use mysql_num_rows()
$num_rows = mysql_num_rows($result);
Related questions
-
JavaScript page loading displaying messages
-
PHP functions return values syntax errors
-
FastCGI access permissions phpMyAdmin