-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.

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425

1 Answers1

1

Well, apparenly $result is boolean (as the warning suggests) and the only possibility is to be false as per the mysqli_query() docs:

Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.

Which in turn means that your $result = mysqli_query() has failed.

geomagas
  • 3,190
  • 1
  • 14
  • 27