473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2936
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

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

Similar topics

0
by: Irene Mettias | last post by:
Hello, I've just installed perl DBI v1.38 which according to the documentation supports the method last_insert_id(). For some reason the return value I get is undef. Here is my source code :...
6
by: jim | last post by:
Hi, I have a site with various parts which allow users to enter info via forms which gets entered into various tables in a MySQL db (I'm using ASP, rather than PHP). I have an ecards bit, and...
3
by: Vic Spainhower | last post by:
Hello, I am trying to get the value of the Auto-Incremented key that was assigned using LAST_INSERT_ID(). However, when I execute the following PHP statements after the insert I only get: "value...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
2
by: effendi | last post by:
Hi I tested the following function in Safari and it doesnt work. This is tested fine in IE. function processOutcome(){ mainDatabase=document.forms.AssessDatabase.value var...
1
by: simbarashe | last post by:
I am trying to insert an auto_increment value into multiple tables but its seems to lose its value after the the second insert statement and my code is as follows can any1 please help. The...
1
by: bs9999 | last post by:
Can someone please tell me why when i use <object>.clondeNode that when I appendChild it to my document, the new node doesnt properly work? I'm making a clone of a <scriptand <linknode from an...
6
by: DanWeaver | last post by:
I must be doing some daft thing- In Management Studio Express I have Northwind, Pubs and a db of my own. I can create SQL select queries and get results back fine but when I try to do an insert,...
2
by: WebSnozz | last post by:
I am losing the leading zeros when I get autoincrement IDs from a column with ZEROFILL enabled. I would like to have the leading zeros. I have tried both the php function last_insert_id as well...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.