我試着來顯示所有原材料在我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'已被棄用,它的開發狀態是「僅維護」,它可能不會在近期得到支持。http://www.php.net/manual/ en/mysqlinfo.api.choosing.php – Jacques