Hello (Again)
I am trying to insert recordes into two tables with the following code. But
field UserId in table tOrders
and
field OrderID in table tOrderItem
are not updating only the default value 0 is being saved into the records. I
have been pondering this one all day. I expect as I am new to php I am
missing something obvious but I cannot see it. All the other fields are
being created OK and the $_SESSION[username] is OK as it can be echoed on
the page. I suspect it must be something to do with the variables in the SQL
statements.
*************** *************** *************** *************** **********
<?php
session_start() ;
include('iddsof 2.php');
include("login. php");
$OrderDate = date('d/m/Y');
echo $_SESSION[username];
$UserID = mysql_query("SE LECT id FROM users WHERE username
='".$_SESSION[username]."'");
$OrderID = mysql_query("SE LECT OrderID FROM tOrders WHERE UserID =
'$UserID'");
$insertOrder = "INSERT INTO tOrders (UserId,OrderDa te,OrderCost) VALUES
('$id','$OrderD ate',10)";
$add_order = @mysql_query($i nsertOrder) or die('Query failed: ' .
mysql_error());
$insertOrderDet ails = "INSERT INTO tOrderItem (OrderID,Questi onNo) VALUES
('$OrderID',10) ";
$add_order_deta ils = @mysql_query($i nsertOrderDetai ls) or die('Query failed:
' . mysql_error());
?>
<h1>Order Status</h1>
<p>Congratulati ons <b><?php echo $_SESSION[username] ?></b>, your order has
been completed.<br>
Please check that the questions have transfered to your local database from
within Pupil Tester.<br><br> <br><br>
<a href=\logout.ph p\> Logout</a> or return to <a href=\Questions .php\>
Questions Database</a></p>
<?php
mysql_close($co nn);
?>
*************** *************** *************** *************** ***********
I am trying to insert recordes into two tables with the following code. But
field UserId in table tOrders
and
field OrderID in table tOrderItem
are not updating only the default value 0 is being saved into the records. I
have been pondering this one all day. I expect as I am new to php I am
missing something obvious but I cannot see it. All the other fields are
being created OK and the $_SESSION[username] is OK as it can be echoed on
the page. I suspect it must be something to do with the variables in the SQL
statements.
*************** *************** *************** *************** **********
<?php
session_start() ;
include('iddsof 2.php');
include("login. php");
$OrderDate = date('d/m/Y');
echo $_SESSION[username];
$UserID = mysql_query("SE LECT id FROM users WHERE username
='".$_SESSION[username]."'");
$OrderID = mysql_query("SE LECT OrderID FROM tOrders WHERE UserID =
'$UserID'");
$insertOrder = "INSERT INTO tOrders (UserId,OrderDa te,OrderCost) VALUES
('$id','$OrderD ate',10)";
$add_order = @mysql_query($i nsertOrder) or die('Query failed: ' .
mysql_error());
$insertOrderDet ails = "INSERT INTO tOrderItem (OrderID,Questi onNo) VALUES
('$OrderID',10) ";
$add_order_deta ils = @mysql_query($i nsertOrderDetai ls) or die('Query failed:
' . mysql_error());
?>
<h1>Order Status</h1>
<p>Congratulati ons <b><?php echo $_SESSION[username] ?></b>, your order has
been completed.<br>
Please check that the questions have transfered to your local database from
within Pupil Tester.<br><br> <br><br>
<a href=\logout.ph p\> Logout</a> or return to <a href=\Questions .php\>
Questions Database</a></p>
<?php
mysql_close($co nn);
?>
*************** *************** *************** *************** ***********
Comment