Please help me! :(

From: Date: Sun, 24 Mar 2002 04:42:25 +0000
Subject: Please help me! :(
Groups: php.db 
Request: Send a blank email to php-db+get-17863@lists.php.net to get a copy of this message
I have a site where things in the database have ids. When something new is added, it gets an id one higher than the highest existing id. I use code something like this: $gethighestid = mysql_fetch_array(mysql_query("select id from table order by id desc limit 1")); $tobeid = $gethighestid[id]+1; mysql_query("insert into table(id,othercolumn,othercolumn2) values('$tobeid','something','something')"); The thing is, I just got two rows with duplicate ids. Aparantley, two people must of added two things at just the right times to make the same id. Is there any way that will reduce, or eliminate, the time gap between getting id and inserting?

« previous php.db (#17863) next »