|
Posted by Ian Davies on 10/23/05 01:30
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('iddsof2.php');
include("login.php");
$OrderDate = date('d/m/Y');
echo $_SESSION[username];
$UserID = mysql_query("SELECT id FROM users WHERE username
='".$_SESSION[username]."'");
$OrderID = mysql_query("SELECT OrderID FROM tOrders WHERE UserID =
'$UserID'");
$insertOrder = "INSERT INTO tOrders (UserId,OrderDate,OrderCost) VALUES
('$id','$OrderDate',10)";
$add_order = @mysql_query($insertOrder) or die('Query failed: ' .
mysql_error());
$insertOrderDetails = "INSERT INTO tOrderItem (OrderID,QuestionNo) VALUES
('$OrderID',10)";
$add_order_details = @mysql_query($insertOrderDetails) or die('Query failed:
' . mysql_error());
?>
<h1>Order Status</h1>
<p>Congratulations <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.php\> Logout</a> or return to <a href=\Questions.php\>
Questions Database</a></p>
<?php
mysql_close($conn);
?>
***********************************************************************
[Back to original message]
|