I think the message you are getting is that there is a good connection to the database server. I do not think you have yet inserted yet. Try $result = mysql_query($queryNo) or die("Invalid query: " . mysql_error()); somewhere before > $id= mysql_insert_id();
--- "Trusz, Andrew" <[EMAIL PROTECTED]> wrote: > No difference. The id and '' combination works fine > in the mysql interface. > My main question is: is the use of mysql_insert_id() > correct? > > There may be a problem with the connection between > the php and mysql on this > machine. I'll try the code on one I know works > later. But I wanted to know > if the use of the insert)_id function was proper > since it doesn't work on > the mysql command line interface. > > If I can't get that to work, I'll have to use an > ugly single table or invent > a more elaborate way of setting up the id. > > drew > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Sent: Friday, February 13, 2004 12:13 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: [wdvltalk] Re: php > > $Query = "Insert into $TableName (id, name, date) > values ('', 'number > three', '2004-12-02')"; > > loose all references to id.... making... > $Query = "Insert into $TableName (name, date) values > ('number three', > '2004-12-02')"; > > My first thought was that you're forcing a blank > into the id field... > Try this... no pormises though... > (It's friday, and I'm 2 mins from leaving.. sorry) > > > > > > [EMAIL PROTECTED] > 13/02/2004 17:09 > Please respond to > [EMAIL PROTECTED] > > > To > [EMAIL PROTECTED] > cc > > Subject > [wdvltalk] php > > > > > > > I’m trying to do multi-table insert using an auto > incremented “id” from > the main table (register) as the id in the second > table (money). I can > establish the connection to the database and I can > insert into each table > using the mysql command line. So the pieces fit. The > script runs but > nothing is added to the tables. As you’ll see, > I’m trying to use > mysql_insert_id() to get the id from the insert into > the main table to use > as a value in the additional table. > > I get the “success” message and an id of 0 when > it should be 3 and no data > inserted in either table. > > <?php > /* Set variables for database access */ > $Host = "localhost"; > $User = "root"; > $Password = ""; > $DBName = "MySQL.respite"; > $TableName = "register"; > $TableName2 = "money"; > > $Link= @mysql_connect($Host, $User, $Password) or > die(mysql_error()); > if ($Link) { > $msg = "success"; > } > $Query = "Insert into $TableName (id, name, date) > values ('', 'number > three', '2004-12-02')"; > $id= mysql_insert_id(); > > > $Query2= "Insert into $TableName2 (id, cc, pay) > values ('$id', > '1234-9857', '3,000')"; > > $Query3 = "Select * from register money where id = > '$id'"; > > mysql_close($Link) > ?> > <? echo "$msg"; ?> > <br /> > <? echo "$id"; ?> > > > drew > > ____ • The WDVL Discussion List from WDVL.COM • > ____ > To Join wdvltalk, Send An Email To: > mailto:[EMAIL PROTECTED] > Send Your Posts To: [EMAIL PROTECTED] > To set a personal password send an email to > [EMAIL PROTECTED] with the > words: "set WDVLTALK pw=yourpassword" in the body of > the email. > To change subscription settings to the wdvltalk > digest version: > http://wdvl.internet.com/WDVL/Forum/#sub > > ________________ http://www.wdvl.com > _______________________ > > You are currently subscribed to wdvltalk as: > [EMAIL PROTECTED] > To unsubscribe send a blank email to %%email.unsub%% > > To unsubscribe via postal mail, please contact us > at: > Jupitermedia Corp. > Attn: Discussion List Management > 475 Park Avenue South > New York, NY 10016 > > Please include the email address which you have been > contacted with. > > > > > > ********************************************************************* > The information contained in this e-mail message is > intended only for > the personal and confidential use of the > recipient(s) named above. > If the reader of this message is not the intended > recipient or an agent > responsible for delivering it to the intended > recipient, you are hereby > notified that you have received this document in > error and that any > review, dissemination, distribution, or copying of > this message is > strictly prohibited. If you have received this > communication in error, > please notify us immediately by e-mail, and delete > the original message. > *********************************************************************** > > N > RÊ.売Ȩ`,#ṌNh|[ZD'f䠢:&j)m > o֥:"X宾W('u.,жd+- > o&N > ^'jZZ郲(쯭卝֧zf%g+- > o&祲+alV > R*.. > +v)ͅw*N!jxr*'mx,롶a{ > o֥ؠzoz哻"xm{^wrX5KZ+o刽m > 0v\f(Ṫr > z{e > > mm > o֥;,j > /N > rzǧujy䙨^jv獩mjY5]ུb0v捥\d{.n䐠+h֥W(岞ᴛbh*+ > m䁜8r,㊉´Ljv匠zg=* > M{(献CXM5^j呻nu␝ay隊Vvbry'邵-y" > > ____ The WDVL Discussion List from WDVL.COM ____ > To Join wdvltalk, Send An Email To: > mailto:[EMAIL PROTECTED] > Send Your Posts To: [EMAIL PROTECTED] > To set a personal password send an email to > [EMAIL PROTECTED] with the words: "set WDVLTALK > pw=yourpassword" in the body of the email. > To change subscription settings to the wdvltalk > digest version: > http://wdvl.internet.com/WDVL/Forum/#sub > > ________________ http://www.wdvl.com > _______________________ > === message truncated === __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html ____ The WDVL Discussion List from WDVL.COM ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.