好的,我在使用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