I am trying to assign LAST_INSERT_ID()
into a variable. When I use LAST_INSERT_ID()
it works but when I do $id = LAST_INSERT_ID();
it doesn't work.
Works:
INSERT INTO pooruser (userid, name) values (LAST_INSERT_ID(), 'Jack')
Doesn't Work:
$id = LAST_INSERT_ID();
INSERT INTO freeuser (userid, name) values ('$id', 'Jack')
I'm not really sure why it won't work. If anyone can help me I would greatly appreciate it!
Also if I can get this to work to store that in a session would I then do $_SESSION('id') = $id;
?
Again, any help is appreciated!