如何解决???
警告:mysqli_fetch_all()期望参数1为mysqli_result,在第14行的E:\ Code \ htdocs \ comment-reply-system \ functions.php中给出布尔值
$user_id = 1;
// connect to database
$db = mysqli_connect("localhost", "root", "", "comment-reply-system");
// get post with id 1 from database
$post_query_result = mysqli_query($db, "SELECT * FROM posts WHERE id=1");
$post = mysqli_fetch_assoc($post_query_result);
// Get all comments from database
$comments_query_result = mysqli_query($db, "SELECT * FROM comments WHERE post_id=" . $post['id'] . " ORDER BY created_at DESC");
$comments = mysqli_fetch_all($comments_query_result, MYSQLI_ASSOC);
答案 0 :(得分:0)
看起来您的$comments_query_results
变量的值为false。
出问题了。
您可以通过在查询后键入此错误来调试错误
if(!$comments_query_result) {
echo("Error description: " . mysqli_error($db));
}