mysql_insert_id() is a PHP function for it.
however I recommend you using a build-in SQL function LAST_INSERT_ID().

i.e: INSERT INTO table SET name='$name', surname='$surname';
UPDATE table SET name='$name', surname='$surname' WHERE id=LAST_INSERT_ID()

Cheers,
Maxim Maletsky

-----Original Message-----
From: Sandeep Hundal [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 02, 2001 12:44 PM
To: PHP General
Subject: [PHP] How do I get last inserted ID?


Hi All,

just a quick question. Say my script is inserting values into a
database, which has an autoincremental id. Now I usually send out a
mail also with the contents of the inserted stuff. The only problem
is that of the ID field. How can I get the script to determine what
id number was given to that row?

thanks

/sunny

__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to