954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

using last_insert_id()

i have to run 2 queries for inserting 2 different tables

userorder table contains orderid , title

order_details containts orderid, qty

so how can i get orderid for my order_details? the code below donts seems able to get last orderid

$query = mysql_query("SELECT last_insert_id()");

list($oid)=mysql_fetch_row($query);
issaru07
Light Poster
40 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

You can use mysql_insert_id() function after your insert query.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 
You can use mysql_insert_id() function after your insert query.

i got this error, is it the right way to use insert_id() ?

Fatal error: Call to undefined method MySQL::insert_id() in D:\xampp\htdocs\book\checkout-process.php on line 40

$oid = $db->insert_id();
issaru07
Light Poster
40 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You