我可以使用sql server management studio打开sqlserver 2000数据库,
但我无法使用相同的用户名和密码在php页面中打开相同的数据库。
问题是什么?
if(!$dbSource->open("192.168.4.241:1433","sa","sa","NorthWind"))
{
echo "Fail to open the sql server 2000 database";
}
-----------------------
function open($db_server, $db_user, $db_password, $db_name)
{
$this->conn = mssql_connect($db_server, $db_user, $db_password);
if(!$this->conn)
{
return false;
}
@mssql_select_db($db_name, $this->conn);
return true;
}
答案 0 :(得分:0)
让mssql_get_last_message()告诉您问题所在。
function open($db_server, $db_user, $db_password, $db_name)
{
$this->conn = mssql_connect($db_server, $db_user, $db_password);
if(!$this->conn)
{
echo '<pre>Debug: mssql_connect failed, reason: ', htmlspecialchars(mssql_get_last_message()), '</pre>';
return false;
}
if ( false===@mssql_select_db($db_name, $this->conn) ) {
echo '<pre>Debug: mssql_select_db failed, reason: ', htmlspecialchars(mssql_get_last_message()), '</pre>';
return false;
}
return true;
}