Home  >  Article  >  Database  >  Why Does `mysqli_fetch_array()` Return a Boolean Instead of a Result?

Why Does `mysqli_fetch_array()` Return a Boolean Instead of a Result?

Susan Sarandon
Susan SarandonOriginal
2024-11-20 20:16:12771browse

Why Does `mysqli_fetch_array()` Return a Boolean Instead of a Result?

mysqli_fetch_array() Parameter Compatibility Error

Problem:

You are encountering an error stating that mysqli_fetch_array() expects the first parameter to be a mysqli result, but a boolean value is provided.

Answer:

The error occurs because the mysqli_query() function is not returning a valid mysqli result object. You can add the following code after mysqli_query() to determine the cause of the failure:

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

This will output the error message that is causing the query to fail.

Possible Causes:

  • Incorrect or malformed SQL query
  • Database connection issues
  • Improper usage of database credentials

Additional Information:

For more detailed information on mysqli error handling, refer to the PHP documentation:

  • [mysqli_error()](http://www.php.net/manual/en/mysqli.error.php)

The above is the detailed content of Why Does `mysqli_fetch_array()` Return a Boolean Instead of a Result?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn