This question already has an answer here:
I've looked over all the other questions pertaining to this 'warning' but none are the same as my issue. My issue seems to be quit simple though i just can't seem to figure it out. I've tried every solution i've seen on google and here but i'm not familiar enough with php/mysqli to resolve it. Thanks in advance!
<?php
$db = new mysqli('localhost', 'root', '', 'game');
if($db->connect_errno > 0){
die('Unable to connect [' . $db->connect_errno . ']');
}
$query = mysqli_query($db, "SELECT * FROM `characters`");
$query_result = array();
while ($row = mysqli_fetch_assoc($query)) {
$query_result[$row['id']] = array(
'name' => $row['name'],
'name' => $row['race'],
'name' => $row['level']
);
}
?>
This happens usually when the mysqli_query hasnt run properly. Check whether $query is executed properly or does it contains anything or not. The problem may be with the connection or it may be with the query or it may be with the tables. Be sure $query contains the results.
Try this
Let us know what is the mysql error