"mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given" Error: Troubleshooting in PHP
The "mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given" error in PHP arises when the first parameter passed to mysqli_fetch_array() is not a valid result set from a successful MySQL query.
Problem:
In the provided code snippet, the query "SELECT * FROM users WHERE fb_id = " . $fb_id . " LIMIT 0, 30 " is not executing successfully. As a result, mysqli_query() returns false, which is then passed as the first parameter to mysqli_fetch_array(). This causes the error.
Solution:
To fix the error, you need to ensure that the MySQL query is valid and returns a valid result set. Add the following code after mysqli_query() to check for errors and display them:
if (!$check1_res) { trigger_error(mysqli_error($con), E_USER_ERROR); }
This will output the error message if the query fails, helping you identify the issue.
Possible Causes:
Additional Information:
The above is the detailed content of Why Does My PHP Code Throw \'mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given\'?. For more information, please follow other related articles on the PHP Chinese website!