简体   繁体   English

PHP-mssql_connect():无法连接到服务器

[英]PHP - mssql_connect(): Unable to connect to server

I'm using Apache/2.2.8 (Win32) PHP/5.2.6 on Windows Server 2016. 我在Windows Server 2016上使用Apache / 2.2.8(Win32)PHP / 5.2.6。

I have 2 SQL Server Instances: 我有2个SQL Server实例:
1. 10.201.74.50 1. 10.201.74.50
- Installed on the local Windows Server above. -安装在上面的本地Windows Server上。
- @@VERSION: Microsoft SQL Server 2016 (SP2-GDR) (KB4293802) - 13.0.5081.1 (X64) Jul 20 2018 22:12:40 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor) -@@ VERSION:Microsoft SQL Server 2016(SP2-GDR)(KB4293802)-13.0.5081.1(X64)2018年7月20日22:12:40(c)Windows Server 2016 Standard上的Microsoft Corporation标准版(64位)版权所有(c) 10.0(内部版本14393:)(管理程序)
2. 10.3.3.192\\SQLEXPRESS,1433 2. 10.3.3.192 \\ SQLEXPRESS,1433
- Installed on another Windows Server. -安装在另一台Windows服务器上。
- @@VERSION = Microsoft SQL Server 2005 - 9.00.5000.00 (Intel X86) Dec 10 2010 10:56:29 Copyright (c) 1988-2005 Microsoft Corporation Express Edition with Advanced Services on Windows NT 6.1 (Build 7601: Service Pack 1) -@@ VERSION = Microsoft SQL Server 2005-9.00.5000.00(Intel X86)2010年12月10日10:56:29版权所有(c)1988-2005 Microsoft Corporation Express Edition,具有Windows NT 6.1上的高级服务(内部版本7601:Service Pack 1 )

I can connect to the 2 SQL Server Instances by Microsoft SQL Server Management Studio and Command Prompt as picture below. 我可以通过Microsoft SQL Server Management Studio和命令提示符连接到2个SQL Server实例,如下图所示。 Microsoft SQL Server管理工作室 命令提示符

In case of PHP code, I can connect to the first server, but can't for the second: 如果使用PHP代码,我可以连接到第一台服务器,但是不能连接到第二台服务器:

$link = mssql_connect("10.201.74.50","hoteldw","password");
// mssql_get_last_message(): Changed database context to 'HotelDW'.
// Work

$link = mssql_connect("10.3.3.192\SQLEXPRESS,1433","p","password");
// mssql_get_last_message():
// string(73) "mssql_connect(): Unable to connect to server:  10.3.3.192\SQLEXPRESS,1433"

$link = mssql_connect("10.3.3.192\SQLEXPRESS","p","password"); 
// mssql_get_last_message():
// string(68) "mssql_connect(): Unable to connect to server:  10.3.3.192\SQLEXPRESS"

$link = mssql_connect("10.3.3.192,1433","p","password");
// mssql_get_last_message():
// string(62) "mssql_connect(): Unable to connect to server:  10.3.3.192,1433"

将php安装文件夹上的ntwdblib.dll文件从7.00.839替换为8.00.2039或更高版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM