2009/2/7 revDAVE <Cool@xxxxxxxxxxxxxxxx>: > On 2/7/2009 11:41 AM, "Stuart" <stuttle@xxxxxxxxx> wrote: > >>> Then, after I inserted the record - I would do a quick query that would >>> retrieve the record ID by searching for the random number >> >> Ouch that's nasty!! >> >>> Q: is there a better way to retrieve the record ID from the newly added >>> record? >> >> Use an auto_increment field then, assuming MySQL you can use >> mysql_insert_id to get the ID of the last record inserted on a given >> connection. >> >> -Stuart > > Thanks Stuart - it works great - so much Less Nasty! > > BTW: as long as - mysql_insert_id is right after the insert statement - is > it 100% accurate - (in that no other insert from another user could get in > the middle of this)? Yes. As I stated, it returns the ID of the last record inserted on a given connection. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php