I have changed everything back.
I think it is the "store as field" nope i can only update one record, even with session variable orderid in the clear session,
the only way i can make i work is handcode $NeedInsert = (mysql_num_rows($result) === 0); set to 1
Last thing. If i want to store the productID as well in the order table is it ok to use the cart ID?