Need Help !
|
| Posted: 05/20/2003, 1:15 AM |
|
Hello
Is there a way to get the id of a newly inserted row in a MySQL table ?
I'm using CCS2, php + templates and MySQL...
|
|
|
 |
GreggB
|
| Posted: 05/20/2003, 4:23 AM |
|
|
|
|
 |
GreggB
|
| Posted: 05/20/2003, 4:23 AM |
|
Use " mysql_insert_id() " immediately after an Insert. This will return the most recent Auto_Increment value.
$last_id = mysql_insert_id();
GreggB
|
|
|
 |
Need Help !
|
| Posted: 05/20/2003, 7:05 AM |
|
Thank you for your help GreggB.
But... the problem is that if someone inserts something between the insert query and the mysql_insert_id() i'll get a wrong id (the most recent one)...
|
|
|
 |
GreggB
|
| Posted: 05/21/2003, 5:06 AM |
|
Hmmm...
Maybe using "INSERT DELAYED" with "LOCK TABLE" will work.
GreggB
|
|
|
 |