SQL又是一个混蛋

时间:2018-05-07 21:51:21

标签: sql

我使用的脚本显示数据库中的表格,但它一直给我这个错误:

  

警告:mysqli_fetch_assoc()要求参数1为mysqli_result,第21行的C:\ xampp \ htdocs \ raynerblogger1 \ posts.php中给出布尔值

有人请帮忙

$sql = "SELECT * FROM blogs;";
$result = mysqli_query($conn, $sql);

while ($row = mysqli_fetch_assoc($result)) {
    echo "<div id='message'>";
    echo $row['author']; echo(':') . "<br>";
    echo $row['post'] . "</div>" . "<br>" . "<br>" . "<br>";
}

1 个答案:

答案 0 :(得分:0)

试试这个,我编辑了第1行和第6行:

$sql = "SELECT * FROM blogs";
$result = mysqli_query($conn, $sql);

while ($row = mysqli_fetch_assoc($result)) {
    echo "<div id='message'>";
    echo $row['author'].":". "<br>";
    echo $row['post'] . "</div>" . "<br>" . "<br>" . "<br>";
}