Do the insert missing out auto_increment column and then get it afterwoods 
with.

$key = mysql_insert_id();

This actually is cleared on next database access, there is another function 
that is not (cant remember other function and I may of got them the wrong 
way round).

If you are new to PHP you should look things up in the manual, there is a 
PDF and web searchable version for both MySQL and PHP.  Search for 
AUTO_INCREMENT.

Although I am impressed you are using db list not general one ;)

Ben

At 07:15 P 21/10/01, Brett Conrad wrote:
>Hi.
>
>I'm creating a class mapped to the functions of a guestbook.  Each guestbook
>submission becomes an entry in a db table.  I am using the DB Pear class.
>
>I'm new to PHP and my question is this:
>
>What is the best way to create a method that adds a new guestbook entry and
>returns its auto_increment id.  I could use an "Insert" statement and then a
>"Select" statement to find out what id was added for the record, but that
>seems a little inefficient.  Any ideas?
>
>Thanks for any help.  Much appreciated,
>
>Brett
>
>
>
>--
>PHP Database 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]

**************************************************************
* Ben Edwards                                +352 091 429995 *
* Homepage                http://www.gifford.co.uk/~bedwards *
* i-Contact Progressive Video    http://www.videonetwork.org *
* Smashing the Corporate image     http://www.subvertise.org *
* Bristol's radical news            http://www.bristle.co.uk *
* PGP : F0CA 42B8 D56F 28AD 169B  49F3 3056 C6DB 8538 EEF8   *
**************************************************************


-- 
PHP Database 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