Get SQL ID of last SQL query?
Posted: Mon Mar 24, 2008 7:24 pm
Okay, so basically I have a problem with my image board system i'm trying to write... I need some way of naming the image and LINKING the image to the post.
I was thinking that I could submit the post to the SQL database (the topic/text stuff...) and then get the ID number (from auto-increment ID column in SQL table) and name the image that. That way the post and image are linked by ID number.
My question is, how do I get the number of the last query submitted? I realize I could look at the last thing in the database, but if someone ELSE were to submit a post from another browser at that fraction of a second in-between the submit post text and retrieve ID number of last entry queries... it would get the wrong number.
Is there something like "return ID" or something simple I should know about SQL queries that I could use in this circumstance?
Help is much appreciated. ^_^.
I was thinking that I could submit the post to the SQL database (the topic/text stuff...) and then get the ID number (from auto-increment ID column in SQL table) and name the image that. That way the post and image are linked by ID number.
My question is, how do I get the number of the last query submitted? I realize I could look at the last thing in the database, but if someone ELSE were to submit a post from another browser at that fraction of a second in-between the submit post text and retrieve ID number of last entry queries... it would get the wrong number.
Is there something like "return ID" or something simple I should know about SQL queries that I could use in this circumstance?
Help is much appreciated. ^_^.