-3

I am working on a small project for myself that keeps track of some history for me. I am receiving an error that the result is returning with a boolean. Below is the code that I am using

$result = mysqli_query($con,"SELECT formService, formMilage, formdate from clientcarhistory");

echo "<table border='1'>
<tr>
<th>Service Type</th>
<th>Car Milage</th>
<th>Service Date</th>
</tr>";

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['formService'] . "</td>";
  echo "<td>" . $row['formMilage'] . "</td>";
  echo "<td>" . $row['formDate'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysqli_close($con);

I've tested the sql query within mysql and it returns the proper results in the table. However, when I try to access the table via the code above it returns with the error.

Any help given would be greatly appreciated.

4

1 回答 1

1

好吧,显然$result是布尔值(如警告所示),唯一的可能性是false按照mysqli_query() 文档

失败时返回 FALSE。对于成功的 SELECT、SHOW、DESCRIBE 或 EXPLAIN 查询,mysqli_query() 将返回一个 mysqli_result 对象。对于其他成功的查询,mysqli_query() 将返回 TRUE。

这反过来意味着你$result = mysqli_query()失败了。

于 2013-10-12T20:33:02.350 回答