note 46536 added to function.mysql-insert-id
| From: | ckengche at yahoo dot com | Date: | Thu, 14 Oct 2004 15:53:59 +0000 |
| Subject: | note 46536 added to function.mysql-insert-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78549@lists.php.net to get a copy of this message | ||
Whether mysql_insert_id() returns the correct auto_increment value generated from the last INSERT
statement depends on how you define your AUTO_INCREMENT field in your MySQL table.
It is not sufficient to just specify AUTO_INCREMENT for the field, you need to specify is as PRIMARY
KEY as well.
Eg:
CREATE TABLE imuad (
aid int(8) AUTO_INCREMENT PRIMARY KEY,
....
)
----
Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46536
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46536&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46536&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46536&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46536&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46536&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46536&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46536&report=yes
Search -- http://master.php.net/manage/user-notes.php