我想使用 PHP 连接到 sql server 数据库。
我安装了 xampp 1.7.0(php 5.2) 和 SQLSRV20。我在 php.ini
中添加了扩展,我得到了这个错误:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
server: 10.85.80.229 in C:\xampp\htdocs\xampp\test.php on line 07
代码:
<?php
$myServer = "10.85.80.229";
$myUser = "root";
$myPass = "pass";
$myDB = "testdb";
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
?>
此错误消息是什么意思以及如何连接到 SQL Server?
原文由 maha 发布,翻译遵循 CC BY-SA 4.0 许可协议
对于那些想要使用 Windows Auth 连接到数据库(MSSQL)的用户,在 PHP 7.0 版本中删除了 mssql_connect ‘。所以你可以改用它;