2

I've installed PHP5.3.1 on top of 5.3.0 on my Windows 7 Pro laptop. I've installed Smarty, Pear and the relevant Pear packages. I use a config.php file to set up my development site on Win separately from my production sites which run on Linux. I've checked phpinfo and everything is set up correctly.

Now when I try and open up my Home page (login page) on 5.3.1, It thinks for about a minute, doesn't load, leaving a blank screen, and generates no errors. I've tried hiding parts of the config file and the stumbling block appears to be:

require_once "DB.php";
$db = DB::connect("mysql://root:$dbpass@$dbhost/$dbname") or die("unable to connect to $dbhost");
$db_hw = DB::connect( "mysql://root:$dbpass@$dbhosthw/egret" ) or die("unable to connect to $dbhost_hw");

My service uses two different database servers. I'm not even getting the die("") statements displaying.

Any suggestions as to what might be wrong?

George

4

1 回答 1

0

这是行不通的。在您的情况下,您使用第二个连接覆盖连接。使用 mysql_connect 或者mysqli_connect你得到一个资源,你可以用指定的资源处理你的查询:

如何在一个网页上连接多个 MySQL 数据库?

但是当您使用 PEAR 时,您访问的是同一个类DB::connect,这会覆盖数据库资源和连接。

disconnect()在您的情况下,您可以在新连接之前调用该函数:

require_once "DB.php";
$db = DB::connect("mysql://root:$dbpass@$dbhost/$dbname") or die("unable to connect to $dbhost");
$db->disconnect();

$db = DB::connect( "mysql://root:$dbpass@$dbhosthw/egret" ) or die("unable to connect to $dbhost_hw");
于 2012-11-22T15:15:58.843 回答