Get key for the data just inserted into db

teammatt3's picture

He has: 2,102 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: 27 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

He has: 2,102 posts

Joined: Sep 2003

Thank you Laughing out loud

They have: 27 posts

Joined: Mar 2007

Anytime Wink

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.