Jump to content

Query doesn't work


kanala

Recommended Posts

please help, this is my php query

<?php$con = mysql_connect("fdb1.awardspace.com:3306","****","****");if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("icegifts_prod", $con);$id = $_GET['id'];$result = mysql_query("SELECT * FROM products WHERE Item_no = $id");while($row = mysql_fetch_array($result)){ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<line 17?>
I keep getting the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/icegifts.awardspace.com/product.php on line 17What's wrong with it?
Link to comment
Share on other sites

If $id is a number (which I strongly believe) it shouldn't be between 2 '. It's only strings that should be surrounded by '.
The code is inside an iframe which has URL www.icegifts.awardspace.com/?id=CM001SO will the $_get['id'] function actually work, or does it only work for urls in the address bar?Edit: oh maybe it should be between ' ' as its not a number, i will try it tommorow. Thanks
Link to comment
Share on other sites

The $_GET array is populated with whatever querystring variables the page receives. If you want to see them all you can do this:print_r($_GET);If the ID is "CM001", then that is a string, so in your SQL query you will need to quote it.

Link to comment
Share on other sites

The $_GET array is populated with whatever querystring variables the page receives. If you want to see them all you can do this:print_r($_GET);If the ID is "CM001", then that is a string, so in your SQL query you will need to quote it.
Thanks so much, it works now.my website (wip) is www.icegifts.awardspace.com, was just wandering what you think of it. to view items, you have to do a blank search, then it will come up with 2 products. click on one to view it.Thanks
Link to comment
Share on other sites

NB: The above address does not work with the www in there.The site is good, though I think the banner title text is a bit ... unprofessional.

Link to comment
Share on other sites

NB: The above address does not work with the www in there.The site is good, though I think the banner title text is a bit ... unprofessional.
Yea that's what I thought, I just can't get the right design.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...