wampserver php5.3.1和Pear:DB问题

时间:2012-11-22 14:53:47

标签: php pear wampserver

我在Windows 7 Pro笔记本电脑上的5.3.0之上安装了PHP5.3.1。我已经安装了Smarty,Pear和相关的Pear包。我使用config.php文件在Win上设置我的开发站点,与在Linux上运行的生产站点分开。我检查了phpinfo,一切都设置正确。

现在,当我尝试在5.3.1上打开我的主页(登录页面)时,它会认为大约一分钟,不加载,留下空白屏幕,并且不会产生任何错误。我试图隐藏配置文件的一部分,绊脚石似乎是:

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");

我的服务使用两个不同的数据库服务器。我甚至没有显示死亡(“”)语句。

关于可能出错的任何建议?

乔治

1 个答案:

答案 0 :(得分:0)

这不起作用。在您的情况下,您使用第二个连接覆盖连接。使用mysql_connect或mysqli_connect,您将获得一个ressource,您可以使用指定的ressource处理您的查询:

How do you connect to multiple MySQL databases on a single webpage?

但是当你使用PEAR时,你访问同一个类DB::connect,这会覆盖db资源和连接。

在您的情况下,您可以在新连接之前调用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");