note 76815 added to function.mysql-insert-id
| From: | (_AT_) | Date: | Tue, 31 Jul 2007 21:06:39 +0000 |
| Subject: | note 76815 added to function.mysql-insert-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129086@lists.php.net to get a copy of this message | ||
Forget about using MAX to get the last inserted id. Race conditions like other users inserting
between your SELECT MAX(.. and your INSERT may render your id unusable.
The WAY to get the id is by using mysql_insert_id() or the mysql SQL function LAST_INSERT_ID().
Take care, if using mysql_insert_id() you should provide the resource returned by the mysql_connect,
not the resultset returned by mysql_query.
----
Server IP: 80.64.47.13
Probable Submitter: 217.127.201.198
----
Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php
Edit -- https://master.php.net/note/edit/76815
Del: integrated -- https://master.php.net/note/delete/76815/integrated
Del: useless -- https://master.php.net/note/delete/76815/useless
Del: bad code -- https://master.php.net/note/delete/76815/bad+code
Del: spam -- https://master.php.net/note/delete/76815/spam
Del: non-english -- https://master.php.net/note/delete/76815/non-english
Del: in docs -- https://master.php.net/note/delete/76815/in+docs
Del: other reasons-- https://master.php.net/note/delete/76815
Reject -- https://master.php.net/note/reject/76815
Search -- https://master.php.net/manage/user-notes.php