<?php
$con = mysql_connect("localhost","teachms_fooduse","science0");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("teachms_foods", $con);

$result = mysql_query("SELECT * FROM Foods");

echo "<table border='1'>
<tr>
<th>Name</th>
<th>Shop</th>
<th>Price</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Name'] . "</td>";
  echo "<td>" . $row['Shop'] . "</td>";
  echo "<td>" . $row['Price] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

Here is my code, i keep getting the error, it does connect to the database, but throws up this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource-What is it? Can someone fix it please

Recommended Answers

All 2 Replies

Read the FAQ.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.