<?php
$dbCon2=mysqli_connect("localhost", "root", "", "dbusers")
or die(mysql_error()."Connection disconnected");
$sql1 = "SELECT * FROM users";
$sql2 = mysqli_query($dbCon2, $sql1);
while($row = mysql_fetch_array($sql2))
{
echo "<tr>";
echo "<td>" . $row['UserID'] . "</td>";
echo "<td>" . $row['Firstname'] . "</td>";
echo "<td>" . $row['Lastname'] . "</td>";
echo "<td>" . $row['Gender'] . "</td>";
echo "<td>" . $row['Email'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "<td>" . $row['Date_joined'] . "</td>";
echo "</tr>";
}
?>
警告:mysql_fetch_array()期望参数1是资源,给定对象
答案 0 :(得分:2)
那是因为你混合了mysql_*
和mysqli
...两个不同的扩展名。
看起来你正在寻找mysqli_fetch_array()
。此外,请确保使用正确的错误捕获..您当前正在使用mysql_error()
来获取错误..我不习惯使用mysqli,但这对我来说似乎不对。
答案 1 :(得分:0)
$sql2 = mysqli_query($dbCon2, $sql1);
while($row = mysql_fetch_array($sql2))
您正在混淆您的API。 mysql_*
与MySQli
尝试跑步:
$sql2 = mysqli_query($dbCon2, $sql1);
while($row = mysqli_fetch_array($sql2, (MYSQLI_ASSOC))