我之前在 mysql 中创建了一个数据库,现在我试图在一个表中列出它的所有值,但是我Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean
在线收到以下错误:while ($row=mysql_fetch_array($result))
这是我的代码:
$con=mysql_connect("localhost","root","");
if (!$con) {
die("Error: " . mysql_error);
}
mysql_select_db("my_db",$con);
$result = mysql_query("SELECT * FROM Users");
echo "<table border='1'>
<tr>
<th>Username</th>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<th>Email adress</th>
</tr>";
while($row=mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "<td>" . $row['emailadress'] . "</td>";
echo"</tr>";
}
echo "</table>";
mysql_close($con);
我读了其他类似的问题,但没有得到答案。