469,128 Members | 1,363 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,128 developers. It's quick & easy.

LAST_INSERT_ID() doesnt work properly

228 100+
hi guys
i would appriciate your coments on this code - when i ran it for the very first time it doesnt see @last = LAST_INSERT_ID() but when i ran it next time it read it properly i need to know it imiedietely after i insert value into session1...

is there any other way to do it? insert into 2 tables at the same time ...?

[PHP]
if(!($sessid)){
session_register('sessid');
mysql_query("insert into session1 set
sessid=null,
ip='$ip',
ip2='$ip2',
cook=$cook,
time='$time',
user='$Guser',
pass='$pass',
ile='0'
");

//this doesnt work imiedietly last=0 - next time i run the script its ok ..
//it doesnt seem to see that i did inserted a values into session1.
$id5=mysql_query("SELECT @last := LAST_INSERT_ID()");
$sessid1=mysql_fetch_array($id5);
$sessid=$sessid1[0];

mysql_query("insert into session2 set
sessid=@last,
browser='$GLOBALS[HTTP_USER_AGENT]',
lang='$GLOBALS[HTTP_ACCEPT_LANGUAGE]',
host='$GLOBALS[HTTP_HOST]',
accept='$GLOBALS[HTTP_ACCEPT]',
referer='$GLOBALS[HTTP_REFERER]',

");
}[/PHP]


thanks a lot
jx2
Jun 6 '07 #1
3 2666
pbmods
5,821 Expert 4TB
You'll probably like mysql_insert_id.
Jun 6 '07 #2
jx2
228 100+
You'll probably like mysql_insert_id.

doesnt work :-( the same problem.
its doesnt see it imiedietly
it see it when i restart script :-(
Jun 6 '07 #3
jx2
228 100+
ok its working (have to be in order :-)) thanks a lot!!
Jun 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Irene Mettias | last post: by
6 posts views Thread by jim | last post: by
3 posts views Thread by Vic Spainhower | last post: by
2 posts views Thread by effendi | last post: by
1 post views Thread by bs9999 | last post: by
2 posts views Thread by WebSnozz | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.