【发布时间】:2013-10-08 01:49:24
【问题描述】:
我试图在我的family_spouse 表中显示所有原始数据
代码
<?php
$query = "SELECT FROM family_spouse";
$result = mysql_query ($query);
echo "<table border='1'>
<tr>
<th>Family Type</th>
<th>Name</th>
<th>Gender</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['spouse_type'] . "</td>";
echo "<td>" . $row['spouse_name'] . "</td>";
echo "<td>" . $row['spouse_gender'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
当我运行代码时,出现此错误Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\eprofile\dashboard.php on line 598
第 598 行
while($row = mysql_fetch_array($result))
【问题讨论】:
-
SELECT后面缺少一个 *。应该是"SELECT * FROM family_spouse。此外,mysql已被弃用。它的开发状态是“仅维护”,在不久的将来可能不会得到支持。 php.net/manual/en/mysqlinfo.api.choosing.php