Tuesday 12 February 2019

php - Call to a member function fetch_assoc() on boolean in

I'm getting the above error when running the below code to display bookings made from a database.



    

$servername = "localhost";
$username = "*********";
$password = "********";
$dbname = "thelibr1_fyp";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id, tablename, numseats, person FROM confirms";
$result = $conn->query($sql);
?>












while(($row = $result->fetch_assoc()) !== null){

echo
"




\n";
}
?>


Booking ID: Table No.: No. of Seats: Person:
{$row['id']} {$row['tablename']} {$row['numseats']} {$row['person']}



I only started to receive the error when i started hosting it live. It works fine on my personal computer, the databse connection works fine also.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...