(MySql) INSERTing into MULTIPLE tables
| From: | Vladislav Kulchitski | Date: | Wed, 17 Apr 2002 20:03:18 +0000 |
| Subject: | (MySql) INSERTing into MULTIPLE tables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-93386@lists.php.net to get a copy of this message | ||
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