Forums

PHP

This topic is locked

HELP WITH LAST_INSERT_ID()

Posted 14 Sep 2006 22:42:15
1
has voted
14 Sep 2006 22:42:15 dennis brownlie posted:
In the following function I am turning a shopping cart into an order. The order has an order header record and many detail records. I use auto increment to assign the order id and populate the order detail records with order id using the LAST_INSERT_ID() function. Next,I want to store the order id in a session variable but $SESSION['MM_ORDER']=LAST_INSERT_ID(); does not work. what am I doing wrong. Everything else works fine in this function. How does one assign LAST INSERT_UPDATE() to a session variable?

Dennis Brownlie
del mar data systems









function MakeOrder($ItemId,$today,$adminid,$oe_id)
{

mysql_query("INSERT INTO inorder(order_id,admin_id,order_date) values (null,'1',NOW())";
"SELECT last_insert_id() as id_number from INCART";
// the next line does not work
$SESSION['MM_ORDER']=LAST_INSERT_ID();
mysql_query("UPDATE incart SET incart.orderid = LAST_INSERT_ID()";

mysql_query("INSERT INTO inorderdtl( order_id,part_id, price, qty) select orderid,part_id, price, qty from incart where cookieId = '" . GetCartId() . "'";


}

Reply to this topic