kanala Posted March 12, 2008 Share Posted March 12, 2008 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 More sharing options...
justsomeguy Posted March 12, 2008 Share Posted March 12, 2008 The SQL query is failing. Use mysql_error after the query to see the error message, or print the query and look at it. Changes are either the ID is empty or a string. Link to comment Share on other sites More sharing options...
Wander Posted March 12, 2008 Share Posted March 12, 2008 $id should be between ' ' things, (so Item_no = '$id' )try putting: or die(mysql_error());behind the mysql_query() Link to comment Share on other sites More sharing options...
Peppe L-G Posted March 12, 2008 Share Posted March 12, 2008 $id should be between ' ' things, (so Item_no = '$id' )If $id is a number (which I strongly believe) it shouldn't be between 2 '. It's only strings that should be surrounded by '. Link to comment Share on other sites More sharing options...
kanala Posted March 12, 2008 Author Share Posted March 12, 2008 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 More sharing options...
justsomeguy Posted March 12, 2008 Share Posted March 12, 2008 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 More sharing options...
kanala Posted March 13, 2008 Author Share Posted March 13, 2008 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 More sharing options...
Synook Posted March 13, 2008 Share Posted March 13, 2008 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 More sharing options...
kanala Posted March 13, 2008 Author Share Posted March 13, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.