我正在构建一个简单的 PHP CRUD 应用程序,但遇到了这个错误:
警告:mysql_num_rows() 期望参数 1 是资源,布尔值在
<?php
$query = "select * from user";
$result = mysql_query($query);
if (mysql_num_rows($result) > 1) {
echo "<table align='center' border='1'>";
echo "<tr>";
echo "<th>Id</th>";
echo "<th>Username</th>";
echo "<th>Password</th>";
echo "</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['username']."</td>";
echo "<td>".$row['password']."</td>";
echo "<td><a href='index.php?operation=edit&id=".$row['id']."&username=".$row['username']."&password=".$row['password']."'>edit</a></td>";
echo "<td><a href='index.php?operation=delete&id=".$row['id']."'>delete</a></td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<center>No Records Found!</center>";
}
?>
错误指向该代码中的第 34 行。任何帮助将不胜感激!