Can I ask why you're not using "autoincrement" for your
id field? If you used this you would never have the problem
your having.

Everytime a record is added it will increment the id field
by one, so you don't have to use all the code your using.


-----Original Message-----
From: Leif K-Brooks [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 24 March 2002 3:42 PM
Subject: [PHP-DB] Please help me! :(

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)

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?

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to