duanlvji4780 2017-02-28 15:52
浏览 216

无法使用PHP sqlsrv_connect连接 - 找不到服务器

I'm using PHP 7.0.15, running IIS locally, and I'm trying to connect to our main SQL Server box. I have successfully loaded the sqlsrv extension, tested with

echo "Did sqlsrv load? " . (extension_loaded('sqlsrv') ? "YES" : "NO");

which returns YES. The SQL instance on the box I'm connecting to is hdnysql1\hdnysql1, verified with select @@serverName. I've checked that I can connect running SQL Server Management Studio using Windows authentication, and I'm trying to use Windows authentication in the code:

$servername = "hdnysql1\hdnysql1";
$connectionInfo = array("Database"=>"MCDB_Test");
$conn = sqlsrv_connect($serverName, $connectionInfo);

This returns a connection failure; sqlsrv_errors returns an array including

Named Pipes Provider: Could not open a connection to SQL Server
Login timeout expired
A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

I followed the instructions here and verified that remote connections are allowed to the server. The TCP port setting in SQL Server Configuration Manager was blank; I set it to 1433 on IP2, restarted services, and things appear to be working; SSRS had to be restarted too but that's working OK. I telnetted to the server on port 1433 to be sure it was open and disabled my firewall, and still no luck -- still getting the same message. Any help would be much appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?