fetch_assoc() error

Tuesday, November 3, 2015

I am getting an error that says Call to a member function fetch_array() on boolean on line 23.
Line 23 consists of this line of code



$row = $query->fetch_assoc();


Here is the whole block



if(!filter_has_var(INPUT_GET, 'id')) {
echo "Error: book id was not found.";
require_once ('includes/footer.php');
exit();
}
$book_id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);

$sql = "SELECT * FROM books WHERE book_id=" . $book_id;

$query = $conn->query($sql);

$row = $query->fetch_assoc();

0 comments:

Post a Comment