我一直在努力 警告:mysql_fetch_row()期望参数1是资源,在第6行的xx中给出布尔值
错误此代码有什么问题?我该如何解决?
$read = mysql_query("select * from detail");
while($wr = mysql_fetch_array($read)) {
echo $wr['Who'];
echo "<br />";
echo $wr['Time'];
echo "<br />";
echo $wr['What'];
}
编辑;我这样做仍然是错误的。
$db = new mysqli('localhost', 'root', '', 'panel');
$sql = "select * from detail";
$read = $db->query($sql);
while($wr = mysql_fetch_array($read)) {
echo $wr['Who'];
echo "<br />";
echo $wr['Time'];
echo "<br />";
echo $wr['What'];
}
答案 0 :(得分:4)
您正在混合MySQL和MySQLi扩展!
使用其中任何一个的appropriate functions,而不是两者。
答案 1 :(得分:1)
由于查询失败,您可能在查询数据库时遇到问题:
$read = mysql_query("select * from detail"); // $read is false
// You can try to discover the error.
$read = mysql_query("select * from detail") || die(mysql_error());
答案 2 :(得分:0)
使用此代码:
$read = mysql_query("select * from detail");
while($wr = mysql_fetch_array($read, MYSQL_ASSOC)) {
echo $wr['Who'];
echo "<br />";
echo $wr['Time'];
echo "<br />";
echo $wr['What'];
}
有关详细信息,请参阅:mysql-fetch-array