Jump to content

Archived

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

pixeltrace

help on my order form

Recommended Posts

guys i need help

please check http://www.sinagtala.net/products.php

try clicking on the "order now" link on the product items
notice 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">&nbsp;</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">&nbsp;</td>
              <td colspan="3"><span class="bodytext">--------------------------------------------------------------------------------------------</span></td>
              <td>&nbsp;</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>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
              </table>
    </td>
  </tr>
</table>
</body>
</html>
---------------

hope you can help me with this.

thanks!

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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">&nbsp;</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">&nbsp;</td>
              <td colspan="3"><span class="bodytext">--------------------------------------------------------------------------------------------</span></td>
              <td>&nbsp;</td>
            </tr>
          </table>
      <?
}
}
?>
</td>
  </tr>
</table>
</body>
</html>

Share this post


Link to post
Share on other sites
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>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
              </table>
          <?
}
}
?>
</td>
  </tr>
</table>
</body>
</html>

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</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= ''

Share this post


Link to post
Share on other sites
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=17

Also 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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
You were not assigning the result of the query to a variable:

[code]<?php
include '../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>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>[/code]

Share this post


Link to post
Share on other sites
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">&nbsp;</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">&nbsp;</td>
              <td colspan="3"><span class="bodytext">--------------------------------------------------------------------------------------------</span></td>
              <td>&nbsp;</td>
            </tr>
          </table>
      <?
}
}
?></form>
</td>
  </tr>
</table>
</body>
</html>
[/code]

but its producing the same result. the porder.php is still not populating

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
i think the problem is with the porder.php page.

i tried assigning and id =1 in the product_id
[code]<?php
include '../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!

Share this post


Link to post
Share on other sites
<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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.