php查询数据库时出现warning警告

当连接MySQL数据库时出现Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in D:\phpstudy_pro\WWW\localhost\update.php on line 4

以下是源代码:




<?php
include'conn.php'; 
$result=mysqli_query($conn,"select * from db_admin where id={$_POST['id']}");
$arr=mysqli_fetch_assoc($result);
?>
<form method="post" action="update_ok.php">
    <table>
        <tr><th colspan="2">管理员信息</th></tr>
        <tr><td>姓名</td><td><input type="text" name="username" value="<?php echo$arr['username']?>"></td></tr>
        <tr><td>密码</td><td><input type="text" name="password" value="<?php echo$arr['password']?>"></td></tr>
        <tr><td>邮箱</td><td><input type="text" name="email" value="<?php echo$arr['email']?>"></td></tr>
        <tr><td><input type="hidden" name="id" value="<?php echo$arr['id']?>"></td>
            <td><input type="submit" name="submit" value="修改"></td>
        </tr>
    </table>
</form>
<?php 
mysqli_free_result($result);
mysqli_close($conn);
?>

```

先加一段代码,看具体抛什么错误

if (!$res) {
    printf("Error: %s\n", mysqli_error($conn));
    exit();
}

可以参考一下这个,
https://blog.csdn.net/weixin_45468845/article/details/106339721

如果满意,麻烦采纳,非常感谢