15,397,224 members
1.00/5 (1 vote)
See more:
I am creating a basic website for one of my assignments, which must view a database I created in MyPHPAdmin , add and delete a record.

In my View.php on line 55 which is:

while($row = mysqli_fetch_array($result )).

The following error appears:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\View.php on line 55

Why is this happening and what can I do to resolve this error ?

What I have tried:

Tried using sites similar to this one such as StackOverflow and have not found a solution that answers my question as well as one that I understand as I am a beginner in PHP.
Posted
Updated 7-Jul-22 0:09am
Richard MacCutchan 6-Mar-18 4:09am

Read the MySQL documentation, where this is explained in detail.

## Solution 2

where you are running mysqli_query , add 'or die( mysqli_error($db)' e.g$sql = "SELECT * FROM users";
$result = mysqli_query($db, $sql) or die( mysqli_error($db));

$db being the variable holding the connection to db Comments Member 14212728 4-Apr-19 3:22am not work for db Member 14212728 4-Apr-19 3:23am Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\school_mca\search.php on line 197 //this one error bro// techilo genet 13-Jul-21 19:36pm I have get also this problem Member 14828122 11-May-20 2:25am thanks a lot for this solution sir ## Solution 1 You have to check the return value of the previous PHP: mysqli::query - Manual[^] call for success. If that fails it returns a boolean false instead of a mysqli_result object. See the above link on how to check for errors and report them. Printing the error message is useful to know what went wrong (usually an SQL syntax error). ## Solution 9 if($result){
while ($row = mysqli_fetch_array($result)) {
echo "result is more then 1" }
}
else{
echo "result is empty"
}

## Solution 7

while($row = mysqli_fetch_array($result ))
it is wrong code
$sql="Here is the SQL query";$result=mysqli_query($con,$sql);///$con is your MySQL connection code while($row = mysqli_fetch_array( $result,MYSQLI_ASSOC)){ printe_r($row);
}
/////////////////////////Now all set use it.
techilo genet 13-Jul-21 19:33pm

Fatal error: Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given in C:\xampp\htdocs\codee\takeuser.php:74 Stack trace: #0 C:\xampp\htdocs\codee\takeuser.php(74): mysqli_fetch_array(false, 1) #1 {main} thrown in C:\xampp\htdocs\codee\takeuser.php on line 74 ## Solution 12 i want to print my invoice report but this error sowing . How can I solve ? Fatal error: Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given in
C:\xampp\htdocs\Pharmacy-Management\php\manage_invoice.php:80 Stack trace: #0 C:\xampp\htdocs\PharmacyManagement\php\manage_invoice.php(80): mysqli_fetch_array(false) #1 C:\xampp\htdocs\Pharmacy-Management\php\manage_invoice.php(19):
printInvoice('3') #2 {main} thrown in C:\xampp\htdocs\Pharmacy-Management\php\manage_invoice.php on line 80
Richard Deeming 27-Jan-22 3:57am

Your question is not a "solution" to someone else's question.

And if you'd bothered to read the existing solutions, you would have seen that they also apply to your error.

## Solution 13

mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\pertandingan mewarna\item.php on line 8