好的,我在使用PHP 5.2.17在IIS 6.0上设置SQL Server 2005时遇到了一些麻烦。SQL Server PHP IIS
我已按照指示安装了所有驱动程序和本机客户端,并且我的phpinfo()输出包含sqlsrv及其适当的设置。
但是,当我尝试使用这个命令连接:
sqlsrv_connect("address,port", array("UID"=>"un", "PWD"=>"pw", "Database"=>"db"));
我碰到下面的错误输出:
Array
(
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -49
[code] => -49
[2] => This extension requires either the Microsoft SQL Server 2008
Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client O
DBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are cu
rrently installed. Access the following URL to download the Microsoft SQL Server
2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?Link
Id=163712
[message] => This extension requires either the Microsoft SQL Server
2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Cl
ient ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers
are currently installed. Access the following URL to download the Microsoft SQL
Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink
/?LinkId=163712
)
[1] => Array
(
[0] => IM002
[SQLSTATE] => IM002
[1] => 0
[code] => 0
[2] => [Microsoft][ODBC Driver Manager] Data source name not found a
nd no default driver specified
[message] => [Microsoft][ODBC Driver Manager] Data source name not f
ound and no default driver specified
)
)
的sqlncli.dll是在windows/system32文件夹下,并php_sqlsrv_52_ts_vc6。 dll在php extensions文件夹中,并设置为在php.ini中加载。
我不知道为什么它说它需要扩展,当phpinfo说扩展已加载,我也不知道它为什么会给ODBC驱动程序管理器错误。
任何有识之士将不胜感激。
========================================
更新/编辑: 我试着用下面的连接和它的工作只是罚款:
odbc_connect("Driver={SQL Native Client};Server=servername;Database=db", "un", "pw");
是否有设置我可以在php.ini可能会阻碍sqlsrv_connect的正常工作会丢失?
这确实是一个常见问题。 – zanlok 2011-02-04 18:27:59
混合模式被启用,我再次检查管理工具中的数据源,sql server和sql本地客户端都在那里。 – Wolftousen 2011-02-04 19:32:39