"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > When does mysqli_fetch_array() show an error \"expects parameter 1 to be mysqli_result, boolean given\"?

When does mysqli_fetch_array() show an error \"expects parameter 1 to be mysqli_result, boolean given\"?

Published on 2024-11-07
Browse:800

When does mysqli_fetch_array() show an error \

mysqli_fetch_array() Expects MySQLi Result, Not Boolean

In the given PHP code, the error "mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given" indicates that the query execution using mysqli_query() has failed and it returned false instead of a mysqli_result object.

The code starts by assigning values to the $fb_id and $locale variables from the $user_profile array. It then executes the following SQL query:

$check1_task = "SELECT * FROM `users` WHERE `fb_id` = " . $fb_id . " LIMIT 0, 30 ";
$check1_res = mysqli_query($con, $check1_task);

If the query execution is successful, $check1_res will contain a mysqli_result object. However, if the query fails due to any reason, it will return false.

To debug the issue, the recommended approach is to use the mysqli_error() function to retrieve the error message and trigger it using trigger_error(). This will provide more information about why the query failed.

if (!$check1_res) {
    trigger_error(mysqli_error($con), E_USER_ERROR);
}

By adding this code after the mysqli_query() line, you can get a detailed error message about the query failure. This should help you identify and resolve the issue.

For more information on this topic, refer to the following resources:

  • PHP mysqli_error() Function: http://www.php.net/manual/en/mysqli.error.php
Release Statement This article is reprinted at: 1729208898 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3