I'm trying to get the last auto increment value inserted into a table.
I am using MySQL v.5 with php v5.3. The table engine is MyISAM.
The manual states this is what should be done
What I get returned is this
"current_field" :null,
"field_count":n ull,
"lengths":n ull,
"num_rows":null ,
"type":null
The insert statement looks like this -
insert into myTable set col1=val1, col2=val2
-
I have also tried it with setting the key value to null, with no further luck
Then I created a test table with just two fields key and fill. I tested the code on the MySQL browser like this -
insert into t values (null,'xyz');
-
-
select last_insert_id();
-
and the value displayed on the console was 0 not the last id.
Any suggestions would be appreciated.
2 1567
Well I finally got it to work.
Here is the php code Dormilich 8,658
Recognized Expert Moderator Expert
The manual states this is what should be done
What I get returned is this - "current_field":null,
-
"field_count":null,
-
"lengths":null,
-
"num_rows":null,
-
"type":null
not really important any more, but the MySQL manual also states that LAST_INSERT_ID( ) returns a BIGINT and not an array/object. so I’d rather assume that the code you used for calling did not expect a single number to be given.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: PT |
last post by:
I got a problem. And thats.....
First of all, I got these three tables.
------------------- ------------------ ----------------------
tblPerson tblPersonSoftware tblSoftware
------------------- ------------------ ----------------------
PID PName PID* SID* SID SWName
--- ...
|
by: Sree |
last post by:
Hello All,
When will it be benefical to return a value from a function as a const reference
?
Say I have classes like this
class B {
public:
int someValue1;
int someValue2;
|
by: Matthias Kaeppler |
last post by:
Hi,
I was wondering why library implementors often
make getter functions return strings by value
(copies). For example, in boost::filesystem the
leaf() function returns an std::string by value.
So does Gnome::Vfs::FileInfo::get_name().
Isn't that unnecessary overhead? I could as well
return by reference to const-string and avoid
|
by: manning_news |
last post by:
I've got the following query in SQL 2000:
select a.SSN, a.MonthName, a.IMClinicDay,
b.IMClinicDay as SecondDay
from tblResidentRotations a
inner join view7 b
on a.SSN = b.SSN
where a.AcademicYear = '2004-2005' and a.SSN = '999999999' and
datename(month, a.IMClinicDateFirst) = b.MonthName
|
by: John Salerno |
last post by:
Ok, I wrote this all by myself, which explains why it doesn't work. It
is meant to take a number and generate the next number that follows
according to the Morris sequence. It works for a single number, but what
I'd like it to do is either:
1. repeat indefinitely and have the number of times controlled elsewhere
in the program (e.g., use...
| |
by: Veeru71 |
last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS
IDENTITY),
is there any way to get the last generated value by DB2 for the
identity column?
I can't use identity_val_local() as the INSERTS are happening in a
different session.
Eg, We have the following table....
|
by: dunkleypilot |
last post by:
Hello,
I have created a database to track the flights on three aircraft owned by the flight school I manage. The relevant fields in the FlightRecords table are Date, AircraftID, HourMeterOut, and HourMeterIn. - = TotalFlightTime.
Each month I generate a report that calculates the total flight time for each aircraft. That report calls a...
|
by: bogdan |
last post by:
Hi,
I have a stored procedure that returns a single value. Example:
SELECT @RowCount = COUNT(*) FROM t WHERE
RETURN @RowCount
I created a data set, table adapter, and adapter's method configured for the
stored proc and as returning a single value. The wizard created an adapter
method that calls SqlCommand.ExecuteScalar(). The...
|
by: Ryan Le Piane |
last post by:
Hi everyone,
I am trying to program a Form Pay Estimator and it calculates the gross pay, taxes owed, and net pay for an individual employee. For some reason my CalculateTaxes method in my Pay() class is not returning the correct value. This is the code I have here:
In my Pay() class:
class Pay
{
//declare variables
...
|
by: ram1592 |
last post by:
how to get grid last column value using c#
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |