Queries from two databases don't work
| From: | Joaquín | Date: | Thu, 19 Jul 2007 07:31:24 +0000 |
| Subject: | Queries from two databases don't work | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-43803@lists.php.net to get a copy of this message | ||
Hello,
I need query tables that are in two different databases so I use mysql_query() with link_identifier, as I've read in the manual, in order to select in wich DB must be made the query.
The problem I have is that the link identifier has no effect.
This example doesn't work
<?php
$conn_1=mysql_pconnect("localhost","usermysql","password");
mysql_select_db("DB1", $conn_1);
$conn_2=mysql_pconnect("localhost","usermysql","password");
mysql_select_db("DB2", $conn_2); // <------ (1)
$result_t1 = mysql_query("SELECT * FROM
Table1inDB1",$conn_1);
$row_t1 = mysql_fetch_assoc($result_t1); // <------ (2)
$result_t2 = mysql_query("SELECT * FROM Table2inDB2",$conn_2);
$row_t2 = mysql_fetch_assoc($result_t2);
?>
It is as if (1) activates DB2 for all the script an in (2) the query is not made in DB1 but in DB2, even using $conn_1.
I have looking in php.ini but I haven't found anything useful.
My environment is php 4.4.2, mysql 4.0.18, IIS, W2000.
Thanks in advance.