473,749 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LAST_INSERT_ID( ) doesnt work properly

228 New Member
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
Jun 6 '07 #1
3 2981
pbmods
5,821 Recognized Expert Expert
You'll probably like mysql_insert_id.
Jun 6 '07 #2
jx2
228 New Member
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 New Member
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
7321
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 : #!/usr/local/bin/perl
6
12671
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 when users send a card, their data is entered into the db via something like: INSERT vars into ecard_tbl....
3
41662
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 of entryID: Resource id #7" after EVERY insert (it never changes). What am I doing wrong? Thanks very much!
8
7836
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 VALUE ENTERED BY THE USER EXISTS IN THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED. For this, I used the reference artiicle "http://msdn.microsoft.com/library/default.asp?url=/library/en-...
2
2830
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 oCheckboxs=document.forms.TeamID if (oCheckboxs=="undefined" )
1
4122
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 auto_increment value that i want to use is the one from the client table and it will insert in the CONTACTS table but it will not in the JOBSHEET and KNOWLEDGE table. last_insert_id() has not worked because i have auto increment fields in all the tables pliz...
1
2482
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 iframe on my page. The cloned node looks fine, and even appends to my document fine. Viewing innerHTML confirms it is appart of my document. The problem is when i do something like alert(myTestVar), where myTestVar was originally a javascript...
6
2266
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, update or delete I get the message: (1 row(s) affected) - making me think all has gone well, however, when I refresh and look at the relevant table nothing has changed. Any tips? ps In learning the basics of SQL server, vs.net, javascript and
2
2968
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 as running a SELECT query and using the result. I am getting the correct id, it is just losing the leading zeros. I have doulbe checked the table in the database, and it does have the leading zeros. Thanks for any help. $result =...
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.