Re: Works with one server and not the other

From: Date: Mon, 24 Jun 2002 23:37:31 +0000
Subject: Re: Works with one server and not the other
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20071@lists.php.net to get a copy of this message
MySQL doesn't support subselects. Look up mysql_insert_id(). It'll return the ID of the last inserted record. Or just break out the second INSERT statement into one "SELECT" and then the actual INSERT. -Mike ----- Original Message ----- From: "Christine Clerc" <christine.clerc@free.fr> To: <php-db@lists.php.net> Sent: Monday, June 24, 2002 2:48 PM Subject: [PHP-DB] Works with one server and not the other > Hi, > > I want to populate two related tables : here is the code > > include ("connect.php"); > $req="select * from tab where num='$mod'"; > $result=mysql_query($req,$db); > > if ($ligne=mysql_fetch_array($result)) > > //if the data is already there do nothing > {continue;} > //otherwise put it in table 1 > $req2="INSERT INTO tab (num) VALUES ('$mod')"; > $result2=mysql_query($req2,$db); > > //and then add the relational element to table 2 > $req4="INSERT INTO inter (id_tab) SELECT id_tab FROM > tab WHERE num='$mod'"; > $result4=mysql_query($req4, $db); > > The first part works fine on both servers (table 1) > Table 2 fills up fine on my machine but not on the server wher it is > supposed to go ! > > Any idea ? > > Christine

« previous php.db (#20071) next »