Jump to content

Last inserted ID - set as variable


Canman2005

Recommended Posts

Hi all

 

I have a insert script which after it has run, prints the last insered ID, using

printf("%d\n", mysql_insert_id());

 

Is there a way to set this number as a variable? I know that

 

$lastidnumber = printf("%d\n", mysql_insert_id());

 

Doesnt work, so is there a way to do this?

 

Also, is this the best way to return the last inserted ID? I am using it as a order id number for a small shopping cart.

 

Any help would be great

 

Thanks

 

Dave

 

Link to comment
https://forums.phpfreaks.com/topic/42280-last-inserted-id-set-as-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.