Hi All,
Can anyone tell me how can i get a last inserted unique user id. Following is my Scenario
Every-time a user is created in my website, all his info will be stored in "user" table except his image details. For image, i am using another table "user_images".
PHP Code:
mysql_query("INSERT INTO `user` (username,password,age,gender) Values ('avc','****','12','1')"); // First user info enters into table
$userid = mysql_insert_id(); // bring last inserted id.
mysql_query ("INSERT INTO `user_images`(`user_id`, `title`, `original_filename`, `stored_filename`, `content_type`)VALUES ('$userid','$title','$realname','$filename','$contenttype')"); // inserted the row with mysql_insert_id as userid
// user_id field is unique in the table
Now, my only issue is if two users are doing this at a time. Is there a possibility of they might be having same "mysql_insert_id" and as user_id in "user_images" table is unique, one user ends up with not storing his image info. Can anyone tell me if it is the correct way to do it?
If there is anyother way to do this, please suggest me.
Bookmarks