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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php