Get key for the data just inserted into db
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
Jacine posted this at 16:57 — 19th April 2007.
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();
teammatt3 posted this at 04:26 — 20th April 2007.
He has: 2,102 posts
Joined: Sep 2003
Thank you
Jacine posted this at 04:29 — 20th April 2007.
They have: 27 posts
Joined: Mar 2007
Anytime
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.