Re: what is wrong about this sniplet?

From: Date: Wed, 24 Jan 2001 17:29:09 +0000
Subject: Re: what is wrong about this sniplet?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36325@lists.php.net to get a copy of this message
The variable $HotelID is the hotelId of the record that I just inserted into database and I want to retrive the Id of that record to insert into another table. what is the correct syntax of using mysql_insert_id in this case? Jack jacky@activelifestyle.com "There is nothing more rewarding than reaching the goal you set for yourself" ----- Original Message ----- From: Samantha Savvakis <samantha@cfs.net.au> To: Jacky@lilst <jacky@activelifestyle.com> Cc: PHP General <php-general@lists.php.net> Sent: Tuesday, January 23, 2001 10:20 PM Subject: RE: [PHP] what is wrong about this sniplet? > HI Jack, > > What is the variable $HotelID ? > > mysql_insert_id - has an optional parameter: link_identifier (the database > handle) > > So in this case, is $HotelID your database handle? If not, then just call > mysql_insert_id() without any parameters. > > Otherwise, it is always best to pass around the database handle so that you > know which connection you are using. > > Sam > > > > -----Original Message----- > > From: Jacky@lilst [mailto:jacky@activelifestyle.com] > > Sent: Thursday, 25 January 2001 03:17 > > To: php-general@lists.php.net > > Subject: [PHP] what is wrong about this sniplet? > > > > > > I have the sniplet to run teh query at the page to insert data as > > shown below. After it is run, there was en error said something like > > "Mysql warning, 0 ( zero) is not Mysql index" and the error > > point to the line using mysql_insert_id($HotelID); > > My limited experience cannot tell me what should I be doing in > > order to get what I need. Any thought? > > ****************************************************** > > file://insert Hotel detail > > $insertHotel = "INSERT INTO Hoteldetail > > (HotelName,HotelLocation, HotelCountry,HotelPostcode, > > HotelTelephone,Hotelfax,HotelURL, > > HotelContactFirstName,HotelContactLastName, HotelRoomProvided, > > HotelEmail) VALUES ('$HotelName', '$HotelLocation', > > '$HotelCountry', '$HotelPostcode', '$Hoteltelephone', > > '$Hotelfax', '$HotelURL', '$HotelContactFirstName', > > '$HotelContactLastName', '$HotelRoomProvided', > > '$HotelEmail')"; > > $resultHotel = mysql_query($insertHotel); > > // retrive latest HotelID > > $latestHotelID = mysql_insert_id($HotelID); > > ****************************************************** > > cheers > > Jack > > jacky@activelifestyle.com > > "There is nothing more rewarding than reaching the goal you set > > for yourself" > > >

« previous php.general (#36325) next »