Forum Moderators: coopster
I'm writing a shopping cart and I need to receive the ID of the order that has just been inserted.
Obviously I've used mysql_insert_id and I've put it AFTER the insert query. The insert works fine and the order_id field is incrementing fine but mysql_insert_id still returns '0'.
Does anyone know what the problem might be?
Here's the code...
$insertOrder = "INSERT INTO orders (*Field Names Here) VALUES (*Variables Here*)";$insertOrder_q = mysql_query($insertOrder, $connect) or die (mysql_error()); // This inserts the order and auto_increments fine
echo mysql_insert_id(); // This always returns 0