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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码