尝试连接到MS SQL服务器,但它显示错误

时间:2016-01-11 07:06:16

标签: php sql sql-server

$username = "*******";
$password = "*******";
$hostname = "180.179.67.205";
$dbname = "**********";

//connection to the database
$dbcon = mssql_connect($hostname, $username, $password)or die("Unable to connect to MSSQL");

//select the database
mssql_select_db($dbname, $dbcon); 
  

调用未定义的函数mssql_connect()

3 个答案:

答案 0 :(得分:1)

确保已设置具有“SQL SERVER身份验证”的用户,该用户有权连接。

并检查

PHPINFO:mssql 启用了MSSQL支持

答案 1 :(得分:0)

在php.ini中启用mssql

;延长= php_mssql.dll

延长= php_mssql.dll

答案 2 :(得分:0)

使用此:

$username = "*******";

$password = "*******";

$hostname = "180.179.67.205";

$dbname = "**********";

//connection to the database

$dbcon = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");

//select the database

mysql_select_db($dbname, $dbcon);

// Call to undefined function mysql_connect()

我将mssql更改为mysql,因为新版本不支持

我建议您在php.ini文件中注释掉; php_mssql.dll并查看错误是否消失。