PDA

View Full Version : get mysql auto increment value


SeeIT Solutions
08-31-2005, 10:03 AM
Is there a php function that returns the mysql next auto increment value?

Or does it have to be done by making a query for MAX(id) then adding 1?

Or is there a sql query that does that for u?

marek_mar
08-31-2005, 10:31 AM
mysql_insert_id() (http://www.php.net/mysql_insert_id)??
When you want to add a new row you don't usually need to know what the ID will be as mySQL will assign the correct ID if you leave that field blank.

SeeIT Solutions
08-31-2005, 11:57 AM
I want to insert a record after uploading a file and the file needs to be named according to the record's id.