Error Message
When using HTML Purifier to filter user input and executing a query using mysqli_query(), you may encounter the error:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
This error occurs when mysqli_num_rows() is called with a boolean value instead of an mysqli_result object.
Solution
The root cause of the error is an issue in the SQL query. In the given code, the query:
SELECT users.*, profile.* FROM users INNER JOIN contact_info ON contact_info.user_id = users.user_id WHERE users.user_id=3");
contains an error: there is no JOIN with the profile table anywhere in the query. To fix this, you need to include the correct JOIN statement in the query.
The corrected query:
SELECT users.*, profile.* FROM users INNER JOIN profile ON contact_info.user_id = users.user_id WHERE users.user_id=3");
The above is the detailed content of Why Does `mysqli_num_rows()` Return 'boolean given' After Using HTML Purifier and `mysqli_query()`?. For more information, please follow other related articles on the PHP Chinese website!