Re: Urgent help needed, sound scary when anyone did that on title :-)

From: Date: Thu, 25 Jan 2001 17:41:41 +0000
Subject: Re: Urgent help needed, sound scary when anyone did that on title :-)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36561@lists.php.net to get a copy of this message
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 jacky@activelifestyle.com "There is nothing more rewarding than reaching the goal you set for yourself" ----- Original Message ----- From: Maxim Maletsky <maxim.maletsky@japaninc.net> To: 'Jacky@lilst' <jacky@activelifestyle.com>; <php-general@lists.php.net> 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:jacky@activelifestyle.com] > Sent: Friday, January 26, 2001 1:21 AM > To: php-general@lists.php.net > 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 > jacky@activelifestyle.com > "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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#36561) next »