Thanx, didn't know about Mysql_insert_id(), it fixed the problem in the basic test script, BUT...
The full implementation is now 'being difficult'.
The full script:
require_once('../Connections/connectMyShop.php');
$fooorderNum = $SESSION['orderNum'];
$fooName = $POST['Name'];
$fooprice = $POST['price'];
$fooqty = $POST['qty'];
$query_cust_exists = "INSERT INTO orderitem (orderNum, Name, price, qty) VALUES ($fooorderNum, $fooName, $fooprice, $fooqty)";
if (!isset($SESSION['orderNum']))
{
mysql_select_db($database_connectMyShop, $connectMyShop);
$query_init_cust = "INSERT INTO customer (orderNum) VALUES (NULL)";
mysql_query ($query_init_cust, $connectMyShop) or die(mysql_error());
$SESSION['orderNum'] = mysql_insert_id();
mysql_query ($query_cust_exists, $connectMyShop) or die(mysql_error());
}
else
{
mysql_select_db($database_connectMyShop, $connectMyShop) or die(mysql_error());
mysql_query ($query_cust_exists, $connectMyShop) or die(mysql_error());
}
The output is:
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 ' Grave Robbers, 7.99, 1)' at line 2
I used the 'foo' variables because MySQL didn't seem to like using $_SESSION etc. in the definition of $query_cust_exists, but maybe it's just the same problem differently reported. The problem seems to be with $fooorderNum, because the POST variables made it far enough to be reported in the output so I assume they're okay. Something fundamental I am missing about session variables?