Warning: mysqli_fetch_array() expects parameter - fix
PHP-MySQLi Tutorial » Warning: mysqli_fetch_array() expects parameter
How can I fix: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in
Sometimes in our PHP code a small error can slip in inadvertently and immediately we will have programming errors.
For this we need to check the error_log.php file to find out more easily the errors in the program.
An example of a device error is like Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in which we find in error_log.php file
Example: a simple code php-mysqli, change parameters on this editor
<?php
$conn = mysqli_connect($host, $user_name, $password, $db_name);
$sql = 'SELECT * FROM products';
while ($number = mysqli_fetch_array($conn, $sql)) { //this is line 46
$id = $number['id'];
}
// more php code gere
?>
In this case we will have error in error log file something like: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in
How to fix: Warning: mysqli_fetch_array() expects parameter ....
In the example above you are passing the connection (which doesn't make sense) and the query command itself.
To solve this mysqli_fetch_array()'s 1st parameter must be a result of a query as:
Example:
replace with this code
<?php
$conn = mysqli_connect($host, $user_name, $password, $db_name);
$sql = 'SELECT * FROM products';
$result = mysqli_query($conn,$sql);
while($number = mysqli_fetch_array($result))
{
// your code here
}
?>
Tags:Tag:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in - php mysqli
Online Editor
This tool makes it easy to create, adjust, and experiment with custom colors for the web.
HTML Templates

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.
CSS HTML Layout

Find here examples of creative and unique website layouts.
Free CSS HTML Menu

Find here examples of creative and unique website CSS HTML menu.