LAST_INSERT_ID() doesnt work properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jx2
    New Member
    • Feb 2007
    • 228

    #1

    LAST_INSERT_ID() doesnt work properly

    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_registe r('sessid');
    mysql_query("in sert 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_quer y("SELECT @last := LAST_INSERT_ID( )");
    $sessid1=mysql_ fetch_array($id 5);
    $sessid=$sessid 1[0];

    mysql_query("in sert into session2 set
    sessid=@last,
    browser='$GLOBA LS[HTTP_USER_AGENT]',
    lang='$GLOBALS[HTTP_ACCEPT_LAN GUAGE]',
    host='$GLOBALS[HTTP_HOST]',
    accept='$GLOBAL S[HTTP_ACCEPT]',
    referer='$GLOBA LS[HTTP_REFERER]',

    ");
    }[/PHP]


    thanks a lot
    jx2
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    You'll probably like mysql_insert_id.

    Comment

    • jx2
      New Member
      • Feb 2007
      • 228

      #3
      Originally posted by pbmods
      You'll probably like mysql_insert_id.

      doesnt work :-( the same problem.
      its doesnt see it imiedietly
      it see it when i restart script :-(

      Comment

      • jx2
        New Member
        • Feb 2007
        • 228

        #4
        ok its working (have to be in order :-)) thanks a lot!!

        Comment

        Working...