bri0987 Posted November 28, 2007 Share Posted November 28, 2007 Table: "ORDERS" The Order_ID field for the table "Orders" is also the Invoice Number for the Customer and is set to auto_increment. The problem I am having: When a customer successfully completes the checkout process (in a custom made shopping cart). PHP INSERTS the customers order information into the MySQL Database table "Orders". The "Thank You Page" for the customer will need to display the Invoice (Order_ID) number to the customer for their reference and to track their order online. I was going to just use PHP and pull the last created Order_ID number and display it to the customer BUT I found that if bandwidth is low and multi customers are ordering at the same time, some customers WILL get other customer Order information... This is BAD. How can I get the Order_ID field that I am currently INSERTing into and capture the ID field and set it into a $_session so that I can display the RIGHT Order_ID to the RIGHT Customer? Any help on this topic will be useful. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 28, 2007 Share Posted November 28, 2007 a great little function that you will love called mysql_insert_id(); returns the primary key of the last mysql insert query, its void do not put the query resource in the () Quote Link to comment Share on other sites More sharing options...
bri0987 Posted November 28, 2007 Author Share Posted November 28, 2007 mysql_insert_id(); is what I was using when I got that bad problem with some customers getting other customer order details... because they were ordering at the same time. > Also what do you mean when you said "it's void do not put the..." Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 28, 2007 Share Posted November 28, 2007 that will never happen, as its the last query of the connection, not in general and the void part is that you don't put any parameters in it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.