Help with PHP and MySQL errors?

Brad G

New member
I am creating a website, and am having a little problem with some of the database stuff.

I have 2000 products or so and each has a product code (comprising of mainly alphanumeric characters, though there are hyphens in some as well).

I am creating a product-view page, where the product detail is shown based on the Product ID, which is in the URL. here is the code:

$ProdID = $_GET['ProdID'];
$result1 = mysql_query("SELECT * FROM Products WHERE (ProdID=$ProdID)");

while($row1 = mysql_fetch_array($result1))
{ (echo etc goes here) }

This works fine for products with a numeric code (i.e. "5140") however products whose codes contain letters (i.e. "ALL052" or "ANC") return the following error:

"mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /content/common.php on line 232"

I am unable to create a separate numeric ID for each product, because the database syncs with our accounting software, so was wondering how to get this to work with the Alphanumeric IDs.

Any help would be greatly appreciated.
 
Back
Top