我收到的错误是在第23行的boolean上调用成员函数fetch_array()。 第23行由这行代码组成
$row = $query->fetch_assoc();
这是整个块
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 :(得分:0)
添加此
$query = $conn->query($sql) or trigger_error($mysqli->error."[$sql]");
if ($query->num_rows > 0) {
while($row = $query->fetch_assoc()) {
}
} else {
echo "0 results";
}
运行查询时始终检查错误。