I am learning how to build a shopping cart using PHP and MySQL. I am testing a basic script that builds the products page. I am getting the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in products.php on line 41
This is line 41:
while($row = mysql_fetch_array($result))
When I run the SQL Query (select * from items order by itemName asc) in PHPMyAdmin I get the desired results. I am not sure what could be causing the problem. Please help!
Here is the PRODUCTS.PHP code:
[php]<?php
// This page will list all of the items
// from the items table. Each item will have
// a link to add it to the cart
include(“db.php”);
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query(“select * from items order by itemName asc”);
?>
Products
Product | Price | Description | Add |
<?php echo $row["itemName"]; ?> | $ <?php echo $row["itemPrice"]; ?> | <?php echo $row["itemDesc"]; ?> | &qty=1">Add Item |
|
|||
Your Shopping Cart >> |
Thank you.