PHP & MySQL: Fixing mysqli_num_rows() Parameter Error
The error "mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given" indicates that the function is expecting a valid MySQL result object as its first parameter, but is being passed a boolean value.
In this case, the issue is caused by the query used in the mysqli_query() call, which contains a syntax error. The issue is with the SELECT statement:
SELECT users.*, profile.* FROM users INNER JOIN contact_info ON contact_info.user_id = users.user_id WHERE users.user_id=3");
The query attempts to perform an inner join between the users and contact_info tables, but there's a missing JOIN clause. The correct query should look like this:
SELECT users.*, profile.* FROM users INNER JOIN profile ON profile.user_id = users.user_id WHERE users.user_id=3");
Once the query is fixed, mysqli_query() should return a valid result object, which can then be passed as the first parameter to mysqli_num_rows().
The above is the detailed content of Why Does `mysqli_num_rows()` Return \'expects parameter 1 to be mysqli_result, boolean given\'?. For more information, please follow other related articles on the PHP Chinese website!