几天来一直在研究stackoverflow。需要使用 PHP 连接到 DB2 数据库。以下代码不返回错误消息或任何有用的信息,而只是在页面后面中断 Javascript。
include(TEMPLATEPATH.'/inc/library/adodb_lite/adodb.inc.php');
$DBName = 'DBNAME';
$Host = 'IPADDRESS';
$User = 'USER';
$Password = 'PASS';
$db = ADONewConnection('db2');
$dsn = "driver={IBM db2 odbc DRIVER};Database=$DBName;hostname=$Host;protocol=TCPIP;uid=$User;pwd=$Password";
if ($db->Connect($dsn)) {
echo "<div style='color:green;font-size:21px;'>Connection Successful.</div>";
} else {
echo "<div style='color:#cc0000;font-size:21px;'>Connection Failed db->Connect(dsn)</div>";
echo 'SQLSTATE: '.$db->ErrorNo()."<br>";
echo 'Message: '.$db->ErrorMsg()."<br>";
}