pixeltrace Posted August 23, 2006 Share Posted August 23, 2006 guys i need helpplease check http://www.sinagtala.net/products.phptry clicking on the "order now" link on the product itemsnotice that the next page is telling me no data found.whats wrong with my script?below is the script for my products page (iframe page)--------------<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? include '../db_connect.php'; $uSql = "SELECT product_image, product_name, product_type, product_desc, product_price, product_id FROM products ORDER by product_type"; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found';}else{ while($uRow = mysql_fetch_row($uResult)){ ?> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="7"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td width="14" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> <td width="84" rowspan="3" align="center" valign="top"> <a href="../images/products/<?= $uRow[0]?>.jpg" target="_blank" class="fotgal"><img src="../images/products/thumbs/<?= $uRow[0]?>.gif" width="70" height="69" border="0"></a></td> <td width="10" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> <td width="243"><span class="bodytext3"> <?= $uRow[1]?> </span></td> <td colspan="2" valign="top"><span class="bodytext">| <?= $uRow[2]?> </span></td> <td width="10" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td colspan="3"><span class="bodytext6"> <?= $uRow[3]?> </span></td> </tr> <tr> <td><span class="bodytext3"> <?= $uRow[4]?> </span></td> <td width="42"> </td> <td width="97" align="center"><a href="porder.php?$product_id=<?= $uRow[5] ?>" class="bodytext7">Order Now</a> </td> </tr> <tr> <td colspan="7"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td colspan="3"> </td> <td colspan="3"><span class="bodytext">--------------------------------------------------------------------------------------------</span></td> <td> </td> </tr> </table> <? } } ?> </td> </tr></table></body></html>--------------and this is the script for the next page-------------<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="18" align="center"> <? include '../db_connect.php'; $uSql = "SELECT product_image, product_name, product_desc, product_type, product_price, FROM products WHERE product_id= '$product_id' "; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found';}else{ while($uRow = mysql_fetch_row($uResult)){ ?> <table width="408" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="408" align="center">You have ordered </td> </tr> <tr> <td align="center"> <table width="36" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666"> <tr> <td width="32" align="center"><img src="../images/products/thumbs/<?= $uRow[0]?>.jpg"></td> </tr> </table></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td align="center"><?= $uRow[1] ?></td> </tr> <tr> <td align="center"><?= $uRow[2] ?></td> </tr> <tr> <td align="center"><?= $uRow[3] ?></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> </td> </tr></table></body></html>---------------hope you can help me with this.thanks! Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/ Share on other sites More sharing options...
AndyB Posted August 23, 2006 Share Posted August 23, 2006 The order now link looks like this:[code]http://www.sinagtala.net/products/porder.php?$product_id=17[/code]I suspect it's meant to be coded so it looks like this:[code]http://www.sinagtala.net/products/porder.php?product_id=17[/code]One dollar sign not needed.edit/update: now since using that also generates a 'no data found' message, I wonder if the problem then is with porder.php in that it's expecting product_id as a global variable which isn't going to be the case with register_globals OFF. Since we can't see code for porder.php, the solution might be to change it to something like this at the start ...[code]<?php$product_id = $_GET['product_id']; // retrieve from URL... more code ...[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79430 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 this is my code for the product item page----------------<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? include '../db_connect.php'; $uSql = "SELECT product_image, product_name, product_type, product_desc, product_price, product_id FROM products ORDER by product_type"; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found';}else{ while($uRow = mysql_fetch_row($uResult)){ ?> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="7"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td width="14" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> <td width="84" rowspan="3" align="center" valign="top"> <a href="../images/products/<?= $uRow[0]?>.jpg" target="_blank" class="fotgal"><img src="../images/products/thumbs/<?= $uRow[0]?>.gif" width="70" height="69" border="0"></a></td> <td width="10" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> <td width="243"><span class="bodytext3"> <?= $uRow[1]?> </span></td> <td colspan="2" valign="top"><span class="bodytext">| <?= $uRow[2]?> </span></td> <td width="10" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td colspan="3"><span class="bodytext6"> <?= $uRow[3]?> </span></td> </tr> <tr> <td><span class="bodytext3"> <?= $uRow[4]?> </span></td> <td width="42"> </td> <td width="97" align="center"><a href="porder.php?$product_id=<?= $uRow[5] ?>" class="bodytext7">Order Now</a> </td> </tr> <tr> <td colspan="7"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td colspan="3"> </td> <td colspan="3"><span class="bodytext">--------------------------------------------------------------------------------------------</span></td> <td> </td> </tr> </table> <? } } ?> </td> </tr></table></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79446 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 this is my code for the porder.php----------<?$product_id = $_GET['product_id'];?><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="18" align="center"> <? include '../db_connect.php'; $uSql = "SELECT product_image, product_name, product_desc, product_type, product_price, FROM products WHERE product_id= '$product_id' "; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found';}else{ while($uRow = mysql_fetch_row($uResult)){ ?> <table width="408" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="408" align="center">You have ordered </td> </tr> <tr> <td align="center"> <table width="36" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666"> <tr> <td width="32" align="center"><img src="../images/products/thumbs/<?= $uRow[0]?>.jpg"></td> </tr> </table></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td align="center"><?= $uRow[1] ?></td> </tr> <tr> <td align="center"><?= $uRow[2] ?></td> </tr> <tr> <td align="center"><?= $uRow[3] ?></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> <? } } ?></td> </tr></table></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79447 Share on other sites More sharing options...
AndyB Posted August 23, 2006 Share Posted August 23, 2006 Start by changing this code:[code] $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found';}[/code]to this:[code] $uResult = mysql_query($uSql, $connection) or die("Error: ". mysql_error(). " with query ". $uSql);[/code]What message do you get? Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79452 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 this is my porder.php script now----------------<?$product_id = $_GET['product_id'];?><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="18" align="center"> <? include '../db_connect.php'; $uSql = "SELECT product_image, product_name, product_desc, product_type, product_price, FROM products WHERE product_id= '$product_id' "; $uResult = mysql_query($uSql, $connection) or die("Error: ". mysql_error(). " with query ". $uSql); ?> <table width="408" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="408" align="center">You have ordered </td> </tr> <tr> <td align="center"> <table width="36" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666"> <tr> <td width="32" align="center"><img src="../images/products/thumbs/<?= $uRow[0]?>.jpg"></td> </tr> </table></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td align="center"><?= $uRow[1] ?></td> </tr> <tr> <td align="center"><?= $uRow[2] ?></td> </tr> <tr> <td align="center"><?= $uRow[3] ?></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table></td> </tr></table></body></html>------------------and this is the error message------------------Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM products WHERE product_id= ''' at line 1 with query SELECT product_image, product_name, product_desc, product_type, product_price, FROM products WHERE product_id= '' Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79469 Share on other sites More sharing options...
AndyB Posted August 23, 2006 Share Posted August 23, 2006 The error means that product_id has no value in porder.php. Note my earlier post where you are attempting to pass $product_id=17 when it should have been product_id=17Also your query is wrong - it's got one comma after the list of fields which should be removed:[code]SELECT product_image, product_name, product_desc, product_type, product_price, FROM products ....[/code]Should be:[code]SELECT product_image, product_name, product_desc, product_type, product_price FROM products ....[/code]If you want to post code of your own, [b]please[/b] wrap it with code tags. Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79478 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 sorry about that.i have removed the comma already and the porder.php is appearing already but the data is not populating.what else is wrong on my script?thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79484 Share on other sites More sharing options...
AndyB Posted August 23, 2006 Share Posted August 23, 2006 [quote author=pixeltrace link=topic=105387.msg420987#msg420987 date=1156364465]what else is wrong on my script?[/quote]Are these changes uploaded to your site? Do you really have any data in the database with that product id? While testing, you can echo the actual query string and then test that query string directly through whatever you use to administer your database tables.[b]$uRow[0] - what's that??[/b] Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79493 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 yes,its already uploaded to my site and it has a database.im totally messed up with this.what should be the proper query for my sql?thanks! Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79581 Share on other sites More sharing options...
hitman6003 Posted August 23, 2006 Share Posted August 23, 2006 You were not assigning the result of the query to a variable:[code]<?phpinclude '../db_connect.php';$uSql = "SELECT product_image, product_name, product_desc, product_type, product_price FROM products WHERE product_id= '" . $_GET['product_id'] . "'";$uResult = mysql_query($uSql, $connection) or die("Error: ". mysql_error(). " with query ". $uSql);$uRow = mysql_fetch_array($uResult);?><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="18" align="center"> <table width="408" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="408" align="center">You have ordered </td> </tr> <tr> <td align="center"> <table width="36" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666"> <tr> <td width="32" align="center"><img src="../images/products/thumbs/<?= $uRow[0]?>.jpg"></td> </tr> </table> </td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td align="center"><?php echo $uRow[1]; ?></td> </tr> <tr> <td align="center"><?php echo $uRow[2]; ?></td> </tr> <tr> <td align="center"><?php echo $uRow[3]; ?></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td bg bgcolor="#E14B19"><img src="../images/spacer.gif" width="4" height="1"></td> </tr> <tr> <td><img src="../images/spacer.gif" width="4" height="4"></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> </td> </tr></table></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79588 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 its still not populating. :(what else is missing here?i even tried changing my first page.goto http://www.sinagtala.net/products.php?url=products/painting.php----------- this is the script for that page-----------------[code]<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><link href="../CSS.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #E7E7DD;}--></style></head><body><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td><form method='post' action='porder.php'> <? include '../db_connect.php'; $uSql = "SELECT product_image, product_name, product_type, product_desc, product_price, product_id FROM products WHERE product_type = 'painting' "; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found';}else{ while($uRow = mysql_fetch_row($uResult)){ ?> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="7"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td width="14" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> <td width="84" rowspan="3" align="center" valign="top"><a href="../images/products/<?= $uRow[0]?>.jpg" target="_blank" class="fotgal"><img src="../images/products/thumbs/<?= $uRow[0]?>.gif" width="70" height="69" border="0"></a></td> <td width="10" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> <td width="243"><span class="bodytext3"> <?= $uRow[1]?> </span></td> <td colspan="2" valign="top"><span class="bodytext">| <?= $uRow[2]?> </span></td> <td width="10" rowspan="3"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td colspan="3"><span class="bodytext6"> <?= $uRow[3]?> </span></td> </tr> <tr> <td><span class="bodytext3"> <?= $uRow[4]?> </span></td> <td width="42"> </td> <td width="97" align="center"><input name="submit" type="submit" value="Order Now"> <input type=hidden value=<?= $uRow[5]?> name=product_id> </td> </tr> <tr> <td colspan="7"><img src="../images/spacer.gif" width="10" height="10"></td> </tr> <tr> <td colspan="3"> </td> <td colspan="3"><span class="bodytext">--------------------------------------------------------------------------------------------</span></td> <td> </td> </tr> </table> <? } } ?></form> </td> </tr></table></body></html>[/code]but its producing the same result. the porder.php is still not populating Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79616 Share on other sites More sharing options...
hitman6003 Posted August 23, 2006 Share Posted August 23, 2006 change this:[code]$uResult = mysql_query($uSql, $connection);[/code]to this:[code]$uResult = mysql_query($uSql, $connection) or die(mysql_error());[/code]Your query may not be returning any results. You may also want to echo it out, then put it into your mysql administration tool of choice and ensure that rows are being returned. Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79620 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 i think the problem is with the porder.php page.i tried assigning and id =1 in the product_id[code]<?phpinclude '../db_connect.php';$uSql = "SELECT product_image, product_name, product_desc, product_type, product_price FROM products WHERE product_id= '1'";$uResult = mysql_query($uSql, $connection) or die("Error: ". mysql_error(). " with query ". $uSql);$uRow = mysql_fetch_array($uResult);?>[/code]and the porder.php was able to populate the data for that specific id.what could be wrong on my page?why is it not getting the id number from my previous page?need help.thanks! Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79624 Share on other sites More sharing options...
AndyB Posted August 23, 2006 Share Posted August 23, 2006 <form method='[b]post[/b]' action='porder.php'>That means the values passed to porder.php will be in the $_[b]POST[/b] array and need to be retrieved as:[code]$product_id = $_POST['product_id'][/code]If you want to use $_GET array variables in porder.php then change the form action to "get" - then porder.php will work with links as well as your form. Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79626 Share on other sites More sharing options...
pixeltrace Posted August 23, 2006 Author Share Posted August 23, 2006 that workeb bro!thanks a lot!this site and forum is really helpful to everyone!;) Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79628 Share on other sites More sharing options...
pixeltrace Posted August 24, 2006 Author Share Posted August 24, 2006 it worked bro!thanks a lot!this site and forum is a huge help to all of us. Quote Link to comment https://forums.phpfreaks.com/topic/18463-help-on-my-order-form/#findComment-79633 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.