I did try mysql_error() to see waht exactly is my problem and here hwat I
really need to know. My sniplet was all correct about using last_insert_id()
and the message from mysql_error(0 tells me that "no selected database".
Although I did use mysql_select_db already and I am sure there is nothing
wrong with that part of code. The real problem is when I don't think I added
user to this database properly previously so I simply went to grab another
username that provide me the access to the database, but unfortunately
different one, stupid me.
So what I cannot do here is that now I have database on mysql server call
"FreeSale" and I need to add user in it, how do I do that properly?
cheers
Jack
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for
yourself"
----- Original Message -----
From: Maxim Maletsky <[EMAIL PROTECTED]>
To: 'Jacky@lilst' <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, January 24, 2001 10:22 PM
Subject: RE: [PHP] Urgent help needed, sound scary when anyone did that on
title :-)


> you know Jacky, there's another, less cool and less reliable way to get
the
> last inserted id:
>
> SELECT id FROM table ORDER BY id DESC;
>
> it will sort them all giving you the biggest id *number* (not what mysql
> keeps) and you can keep it for as many milliseconds your script will run
> more...
>
> So if nothing else works for you - try this...
> (depends on how secure & stable you want your application to be, of
> course...)
>
> Cheers,
> Maxim Maletsky
>
> -----Original Message-----
> From: Jacky@lilst [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 26, 2001 1:21 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Urgent help needed, sound scary when anyone did that on
> title :-)
>
>
> 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"
>
> --
> 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]
>


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