More choices, more fun! Get Opera 9, Free!

Get key for the data just inserted into db

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.
teammatt3's picture
Moderator

He has: 1,831 posts

Joined: Sep 2003

I am creating a registration form for a website. When the information the user enters into the form is verified, it will be inserted into a table (tblStudent) in a MySQL db. The primary key of tblStudent is an autonumber. Is there a way to get the primary key for the user I just inserted into the db? I need to set the primary key for that user to a variable because I need to pass it along to paypal for an IPN script.

Thanks

They have: 25 posts

Joined: Mar 2007

Yon can use mysql_insert_id right after you place the data in tblStudent.

http://us2.php.net/mysql_insert_id

$myautoid = mysql_insert_id();

Smiling

teammatt3's picture
Moderator

He has: 1,831 posts

Joined: Sep 2003

Thank you Laughing out loud

They have: 25 posts

Joined: Mar 2007

Anytime Wink