Hey guys, I'm writing some php code for a store, and I'm having a huge problem. Each time I use the expression:
'while($row = mysql_fetch_array($sql)){'
I get the following error in my browser:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/twice/public_html/SEA/merch/browse.php on line 40
Here is one of my codes:
<?php
include 'db.php';
if(isset($GET['id']))
$ID = $GET['id'];
else
$ID = 1;
// Shipping is 3.50 per unit weight
$ship_factor = 3.5
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Browse Products</title>
<style>
<!--
.ms-color2-main { border-left-style: none; border-right-style: none; border-top-style: none;
border-bottom: 1.5pt solid black; background-color: silver }
.ms-color2-tl { font-weight: bold; color: white; border-left-style: none; border-right-style:
none; border-top-style: none; border-bottom: 1.5pt solid black;
background-color: maroon }
.ms-color2-top { font-weight: bold; color: white; border-left-style: none; border-right-style:
none; border-top-style: none; border-bottom: 1.5pt solid black;
background-color: maroon }
-->
</style>
</head>
<body bgcolor="#669900" link="#FFFF00" vlink="#FFFFFF">
<p><b><font face="Verdana" color="#FFFF00" size="5">Browse Products By Team.</font></b></p>
<table border="1" width="100%" id="table1" class="ms-color2-main">
<!-- fpstyle: 9,011111100 -->
<tr>
<?
$sql = mysql_query("SELECT from Categories");
while($row = mysql_fetch_array($sql)){
?>
<td class="ms-color2-tl"><a href='../store/browse.php?id=<?php echo($row['id']) ?>'> <?php echo($row['description']) ?></a></td>
<?
}
?>
</tr>
</table>
<p> </p>
<?
$sql = mysql_query("SELECT FROM PRODUCTS where Category=") . $ID;
while($row = mysql_fetch_array($sql)){
?>
<p align="center"> </p>
<table border="1" width="100%" id="table2" class="ms-color2-main">
<!-- fpstyle: 9,011111100 -->
<tr>
<td class="ms-color2-tl" width="160">
<img border="0" src='images/<?php echo($row['picurl']) ?>' width="300" height="300"></td>
<td class="ms-color2-top" rowspan="2"><?php echo($row['detail']) ?></td>
<td class="ms-color2-top" width="282" colspan="2">Price: $<?php echo ($row['price']) ?></td>
</tr>
<tr>
<td class="ms-color2-tl" width="160"><?php echo($row['description']) ?></td>
<td class="ms-color2-top" width="141">Shipping: $<?php echo($row['weight'] * $ship_factor) ?></td>
<td class="ms-color2-top" width="141">
<?
if ($row['stockcount']<1)
{
?>
<p align="center">OUT OF STOCK</td>
<?
}
else
{
?>
<p align="center"><a href='../store/buyit.php?id=<?php echo($row['id']) ?>'>BUY IT NOW</a></td>
<?
}
?>
</tr>
</table>
<?
}
?>
</body>
</html>
Any ideas what I'm doing wrong??