Forums

PHP

This topic is locked

retrieve record id after record is inserted?

Posted 12 Mar 2003 03:24:49
1
has voted
12 Mar 2003 03:24:49 A H posted:
Hi, I need to retrieve the id of the freshly inserted record. I've found a post here about it using asp but cant find any info about php. Has anyone done this using php? Thanks.

Replies

Replied 12 Mar 2003 14:17:34
12 Mar 2003 14:17:34 Owen Eastwick replied:
What database are you using?

Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
Replied 13 Mar 2003 07:41:29
13 Mar 2003 07:41:29 A H replied:
mySQL
Replied 13 Mar 2003 13:48:53
13 Mar 2003 13:48:53 Owen Eastwick replied:
You can retrieve the used AUTO_INCREMENT key with the LAST_INSERT_ID() SQL function or the mysql_insert_id() API function. Note: for a multi-row insert, LAST_INSERT_ID()/mysql_insert_id() will actually return the AUTO_INCREMENT key from the first inserted row. This allows multi-row inserts to be reproduced on other servers.

Source: www.mysql.com/doc/en/example-AUTO_INCREMENT.html

Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/

Reply to this topic