我从代码的这一部分得到2个错误,请告诉我如何修复:
•mysqli_query()期望参数1为mysqli,null为null •mysqli_fetch_assoc()期望参数1为mysqli_result,在
中给出null$sql = "SELECT * FROM user";
$result = mysqli_query($conn, $sql); //connect to the database, then run the sql query
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$id = $row['id'];
$sqlImg = "SELECT * FROM profileimg WHERE userid = '$id' ";
$resultImg = mysqli_query($sonn,$sqlImg);
while ($rowImg = mysqli_fetch_assoc($resultImg)) {
echo "<div class ='user-container'>";
if ($rowImg['status'] == 0) {
echo "<img src='uploads/profile".$id.".jpg?".mt_rand()."'>";
} else {
echo "<img src='uploads/profiledefault.jpg'>";
}
echo "<p>".$row['username']."</p>";
echo "</div>";
}
}
}
答案 0 :(得分:-1)
$result = mysqli_query($conn, $sql); //connect to the database, then run the sql query
$ conn未定义。