Re: getting results from INSERT

From: Date: Fri, 26 Oct 2001 12:24:42 +0000
Subject: Re: getting results from INSERT
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-13748@lists.php.net to get a copy of this message
I think you want this. $sql = "INSERT INTO table (cod, nome, email) VALUES ('', '$nome', '$email')"; $result = mysql_query($sql); $cod = mysql_insert_id(); The $cod is the primery key. Hope it helps. Bruno Gimenes Pereti. ----- Original Message ----- From: "Matt Stewart" <matt@netvirtua.com> To: <php-db@lists.php.net> Sent: Friday, October 26, 2001 9:57 AM Subject: [PHP-DB] getting results from INSERT > What i'm after is getting the primary key for a record that's just been > added - I have an image file upload accompanying a database addition, and > the image gets renamed $unique_ID.jpeg > only problem is that the current method inserts the information, which auto > produces the primary key, but the only way i know to extract that is by > doing a SELECT, searching for all the matching values to the ones just > entered, and if two entries are the same(except for the primary key - which > is unknown), the image will replace the earlier entry, rather than the one i > actually want it to be for. Is there a way of returning this primary key > immediately after that record is created? > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#13748) next »