I don't think I can use mysql_insert_id() because the ID field in the tables
are all BIGINT Auto_Increment and I saw that in the manual, it said
mysql_insert_id will not work corerctly with this type of data.
I hope I am wrong though. But if it is as the manual said, what else could I
do?
Direct quote from the manul at the part about mysql_insert_id() is here:
*******************************************
mysql_insert_id() converts the return type of the native MySQL C API
function mysql_insert_id() to a type of long. If your AUTO_INCREMENT column
has a column type of BIGINT, the value returned by mysql_insert_id() will be
incorrect. Instead, use the internal MySQL SQL function LAST_INSERT_ID().
********************************************
cheers
Jack
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for
yourself"
----- Original Message -----
From: Joe Stump <[EMAIL PROTECTED]>
To: Jacky@lilst <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, January 24, 2001 9:25 PM
Subject: Re: [PHP] Urgent help needed, sound scary when anyone did that on
title :-)


> remove the result - so just type $id = mysql_insert_id() and it should
work
> fine.
>
> --Joe
>
>
> On Thu, Jan 25, 2001 at 10:21:17AM -0600, Jacky@lilst wrote:
> > Hi people,
> > I got here the syntax that is suppose to get the id from the "just
inserted" record and store it in value, did not work so far and I cannot see
what is wrong in there, can anyone give me a hint what is wrong here? ( And
the reason I did not use mysql_insert_id here is because the ID field at my
tables are all BIGINT so mysql_insert_id won't work, so I have to use
LAST_INSERT_ID() instead). By the way, the error after the page is executed
keep saying that "Mysql warning : 0 is not Mysql index" ( and point to the
line "$FirstLast = mysql_result($resultlast,0,0);"). And I did echo for the
value of $FirstLast, it showed that there is no value in there.
> >
> > Sniplet is like this: ( I tried to keep this down as much as try to give
most detail at the same time, so apologize for too long sniplet).
> >
> > $sql1 = "insert into firsttable (firstname, lastname)
values('Jack','Chan')";
> > $resultsql1 = mysql_query($sql1);
> > $sqlLastID = "select LAST_INSERT_ID() from firsttable";
> > $resultlast = mysql_query($sqlLastID);
> > $FirstLast = mysql_result($resultlast,0,0);
> >
> > $sql2 = "insert into secondtable (FirsttableID,secfirstname,
seclastname) values('$FirstLast','Jacky','Chany')";
> > $resultsql2 = mysql_query($sql2);
> > $sqlLastIDsec = "select LAST_INSERT_ID() from secondtable";
> > $resultlast2 = mysql_query($sqlLastIDsec);
> > $secondLast = mysql_result($resultlast2,0,0);
> >
> > $sql3 = "insert into Thirdtable
(SecondTableID,FirsttableID,Thirdfirstname, Thirdlastname)
values('$secondLast','$FirstLast','Steve','Chan')";
> > $resultsql3 = mysql_query($sql3);
> > $sqlLastIDthird = "select LAST_INSERT_ID() from Thirdtable";
> > $resultlast3 = mysql_query($sqlLastIDthird);
> > $ThirdLast = mysql_result($resultlast3,0,0);
> >
> > ******************
> > what have I done wrong? Please enlighten me here
> > Thanks
> >
> > Jack
> > [EMAIL PROTECTED]
> > "There is nothing more rewarding than reaching the goal you set for
yourself"
>
> --
>
> Joe Stump, PHP Hacker
> [EMAIL PROTECTED]
> http://www.miester.org/
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to