At 22:39 -0400 5/5/04, Nathan Jones wrote:
> Hi there,

I seem to be having a problem retrieving the last inserted ID for a table.

The query I am using is as follows:


It's far easier than anyone else has mentioned, as of my writing. Just use the PHP function 'mysql_insert_id()' after your insert query. This function has been in the PHP MySQL module since at least sometime during the version 3 cycle. Here's the address to the online PHP documentation for the MySQL module: http://www.php.net/manual/en/ref.mysql.php

This is true, but it's possible that the underlying cause of the problem that results in the query not working on PHP may also affect whether or not mysql_insert_id() returns the desired value. For example, if the SELECT LAST_INSERT_ID() query is not being issued on the same connection as the query that generates the ID, calling mysql_insert_id() might not work, either.

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to