Returning ID

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Returning ID

Post by AliasBDI »

I am running some code that INSERTS a user's information (as inputted in a form) into a MySQL table and then immediately runs a second SELECT query to retrieve that same user's 'userID' (unique ID, auto-incremented data type) to use when appearing in the next page.

I think that my page is executing too fast so that by the time it runs the SELECT query, it is still INSERTing from the last query. I know this because when I 'exit()' the page and echo out the 'userID' (from the SELECT query) it does not show until I refresh the page (making it execute the query a second time).

So my question is this ... is there a way to retrieve the unique ID from the INSERT query?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Post by AliasBDI »

Perfect! Works great! Thanks.
Post Reply