There are two things that might have happened here:
- You've attempted to carry out a query by using code similar to
$resultset = mysql_query(...); but the response from MySQL was an error message, and $resultset contains Boolean FALSE.
- You've carried out a query that doesn't return a resultset, such as an
INSERT or UPDATE query, and $resultset contains Boolean TRUE which just indicates that the query was successful.
While debugging, try the following:
if ( $resultset === false ) {
echo mysql_error();
} else {
// whatever you were doing
}
However, there's a danger of leaving this in production code, which will discloses too much information to non-admin users. Better would be to log the error and display a generic error message to the user.
if ( $resultset === false ) {
$message = 'SQL Error in ' . __FILE__ . '@' . (__LINE__ - 2) . ': ' . mysql_error() . "\n";
error_log($message, 3, ERRLOG); # ERRLOG must be defined
# or send an e-mail to the developer
//error_log($message, 1, $developer_email);
# output an error message to the user. For example:
?>
<p class="error">There was an internal database error.
It's been logged, and we'll look into it. Please try again later.
</p>
<?php
} else {
// whatever you were doing
...
}
Even better than that, switch to PDO and use exceptions.