我想从表中检索所有数据,因此我使用此代码
<?php
include("config.php");
$sql = "SELECT * FROM ".$USERS;
$sql_result = mysqli_query($connection, $sql);
if ($sql_result) {
while ($result = mysql_fetch_assoc($sql_result)) {
echo $result;
}
}
else {
die ('Could not execute SQL query '.$sql);
}
?>
但得到了这个警告:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource,
object given in C:\xampp\htdocs\newSDP\phpscript\users.php on line 6
我该如何解决?
答案 0 :(得分:3)
变化: mysql_fetch_assoc到mysqli_fetch_assoc