HOW TO SAVE mysql_insert_id() value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SamiBH
Forum Newbie
Posts: 1
Joined: Tue Aug 31, 2010 2:48 am

HOW TO SAVE mysql_insert_id() value

Post by SamiBH »

Hello,

I have this: $MSG_id=mysql_insert_id();

How can I save $MSG_id value so i can use it in another query?

thank you
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: HOW TO SAVE mysql_insert_id() value

Post by iijb »

Hi
Can you give some more details.
Also if you want to store it another query you just use that variable.

Regards
iijb
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: HOW TO SAVE mysql_insert_id() value

Post by timWebUK »

Store it in a session.

Code: Select all

session_start();

// ... Code and queries

$_SESSION['userID'] = mysql_insert_id();
Post Reply