|
Posted by John MacLeod on 11/15/05 20:19
Thanks for the reply...
When you say "the code seems incomplete" you are right on the money. I know
just enough about sql and php to get me into trouble...in other words I can
usually get done what I need to but it's not always the best (or proper) way
to do it...and other times it just doesn't work at all.
I added the line... error_reporting( E_ALL ); ...that's a life saver,
thanks for that one...
....however, when I added the... echo htmlspecialchars(
$_SERVER['PHP_SELF'] ); ...I receive the error...
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
/usr/www/users/myaccount/myfolder/admin/print_supplier_order.php on line 67
....if I leave the line the way I had it before, I get the error...
Notice: Undefined variable: enter_data in
/usr/www/users/myaccount/myfolder/admin/print_supplier_order.php on line 73
....this is variable $enter_data which is the name I gave the Submit Button
(name=\"enter_data\").
Basically all I'm trying to do is execute a SQL statement by pressing a
Submit Button on a form...but obviously I don't know how...
Here is the code I have that does list the products to be ordered, but has
the error mentioned above and of course will not work if I press the submit
button...
<?php
session_start();
include ("config.php");
include( "settings.inc.php");
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<head>
<title><?echo"$la_supplier_order";?></title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<style type="text/css">
<!--
@import url(<?echo"$site_url";?>/admin/style.css);
-->
</style>
</head><?
///// to have the page print automatically /////
//
// echo"<body bgcolor=\"#ffffff\" onLoad=\"javascript:window.print();\">";
//
///// to have the page print automatically /////
echo"<body bgcolor=\"#ffffff\">";
// view order content
// find all order records from database
////$sql_select = mysql_query( "SELECT SUM(quantity) as total_quantity FROM
".$prefix."store_order_inv");
$sql_select = mysql_query( "SELECT `product`, `title`, `quantity`, `price`,
`cart_order_id` FROM ".$prefix."store_order_inv WHERE `order_from_supplier`
=1 ORDER BY `product` ASC");
// $sql_select = mysql_query( "select `product`, `title`, `quantity`,
`price`, `cart_order_id` from ".$prefix."store_order_inv");
$totalrows = mysql_num_rows($sql_select);
echo" <center><font face=\"arial\" size=\"4\">Order from Supplier<br></font>
<font face=\"arial\" size=\"2\">$date</font></center><br><br>";
////// Reset database button /////////
//////
echo"<form name=\"reset_database\" method=\"post\" action=\"<? $PHP_SELF
?>\">
<center><input type=\"submit\" name=\"enter_data\" value=\"Reset database
after printing\"></center>
</form>";
error_reporting( E_ALL );
if ($enter_data) {
$sql = mysql_query("UPDATE cubecartstore_order_inv SET order_from_supplier
= '0'");
}
////// UPDATE `cubecartstore_order_inv` SET `order_from_supplier` = '0'
////// Reset database button /////////
echo"<table align=\"center\" width=\"95%\" border=\"0\" cellspacing=\"0\"
cellpadding=\"0\">
<tr><td bgcolor=\"$colour_1\">
<table cellpadding=\"2\" cellspacing=\"1\" border=\"1\" width=\"100%\"
align=\"center\">
<tr bgcolor=\"$colour_1\" height=\"20\"
background=\"../images/bevel_bg.gif\">
<td align=\"center\" height=\"20\" background=\"../images/bevel_bg.gif\"
nowrap><b>Product</b></td>
<td align=\"center\" height=\"20\" background=\"../images/bevel_bg.gif\"
nowrap><b>Title</b></td>
<td align=\"center\" height=\"20\" background=\"../images/bevel_bg.gif\"
nowrap><b>Quantity</b></td>
<td align=\"center\" height=\"20\" background=\"../images/bevel_bg.gif\"
nowrap><b>Price</b></td>
<td align=\"center\" height=\"20\" background=\"../images/bevel_bg.gif\"
nowrap><b>Order ID</b></td>
</tr>";
if($totalrows==0){echo"<br><br><p align=\"center\">No products in your
inventory</p>";}
if($totalrows!==0){
while ($row = mysql_fetch_array($sql_select)){
$product=$row["product"];
$title=$row["title"];
$quantity=$row["quantity"];
$price=$row["price"];
$cart_order_id=$row["cart_order_id"];
//echo"
// <tr bgcolor=\"$bgcolour\">
echo"<td align=\"center\">$product</td>
<td align=\"left\">$title</td>
<td align=\"center\">$quantity</td>
<td align=\"center\">$currency $price</td>
<td align=\"center\">$cart_order_id</td>
</tr>";
}// end while
echo"</table></td></tr></table><br>";
}
echo"</body></html>";
?>
I would assume the problem lies somewhere in the line...
$sql = mysql_query("UPDATE cubecartstore_order_inv SET order_from_supplier
= '0'");
....I don't know how to use the $sql variable...I tried taking "$sql =" out
of the line but that didn't work either...
I just want mysql_query() to execute the SQL statement when I press the
submit button...
Thanks for any help you can provide,
John
"Hilarion" <hilarion@SPAM.op.SMIECI.pl> wrote in message
news:dld2qm$s4f$1@news.onet.pl...
>> echo"<form name=\"reset_database\" method=\"post\" action=\"<? $PHP_SELF
>> ?>\">
>
> The line above will give wrong results (or causes parse error). Replace it
> with something like:
>
> echo '<form name="reset_database" method="post" action="';
> echo htmlspecialchars( $_SERVER['PHP_SELF'] );
> echo '">';
> // next lines should be also echoed
>
> or something like:
>
> ?>
> <form name="reset_database" method="post"
> action="<?php echo htmlspecialchars( $_SERVER['PHP_SELF'] ); ?>">
> <!-- next lines -->
> <?php
> // PHP code here
>
>> <center><input type=\"submit\" name=\"enter_data\" value=\"Reset database
>> after printing\"></center>
>> </form>";
>> if ($enter_data) {
>> $sql = "UPDATE cubecartstore_order_inv SET order_from_supplier = '0'";
>> }
>
>
> You should also place this at the very start of your script:
> error_reporting( E_ALL );
>
> and use all database error reporting functions in all possible places.
>
> The code seems to be incomplete. You did not use any database functions
> nor did you use your $sql variable in any way. Post the complete
> script or better strip your script to the form which is complete
> (should perform the action you want) but still does not behave the
> way you want it to (you should test it) and post the stripped script.
>
>
> Hilarion
[Back to original message]
|