That's fine, but you don't need the intermediate select step. Just use mysql_insert_id() to get the value of userid. auto_increment values are guaranteed to be unique no matter how quickly you are inserting.
miguel On Wed, 17 Apr 2002, Vladislav Kulchitski wrote: > Hi, I was wondering if the way I am inserting into multiple tables is > safe as far as when there are many simultaneous insertions at a given > time. > > Basically, there are two tables, first I insert into main table where > there's username and password (and first/last name, email) and then I > get the auto_number from that table for the record and insert that > auto_number along with more info into secondary table with more info > about the user. > > > > $query4accounts="insert into accounts (username, password, fname, lname, > email) values ('$username', password('$password'), '$fname_eng', > '$lname_eng', '$email')"; > > $result=mysql_query($query4accounts) or die ("ERROR"); > > $getid=mysql_query("select * from accounts where username='$username'"); > > $tmp=mysql_fetch_array($getid); > $userid=$tmp['userid']; > > $query4gallery="insert into talkroom_gallery (userid, talkroom_active, > sex, about_eng, livenow_eng, photograph, emailnopublic, homepage, icq, > msn, aim, yahoo) values ('$userid', '$talkroom_active_variable', '$sex', > '$about_eng', '$livenow_eng', '$photograph', '$nopublic', '$homepage', > '$icq', '$msn', '$aim', '$yahoo')"; > > mysql_query($query4gallery) or die ("ERROR"); > > > Thanks in advance for feedback and possible alternatives. > Vlad > http://vladik.tripod.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php