php連接mssql失敗的解決方法:1.在php.ini檔案中找到extension=php_mssql.dll並去掉前面的分號;2、把php_mssql.dll檔案複製到「c:/windows/ system32/”目錄下;3、重啟iis。
本文操作環境:windows7系統、PHP5版、DELL G3電腦
php連線mssql失敗怎麼辦?
關於PHP無法連接MSSQL資料庫的解決方法:
php 資料庫sql server extension sqlserver 伺服器
今天接到一個問題要php5 iis6 mysql5的平台環境上存取sqlserver2000的數據,結果運行時發現php連接遠端mssql資料庫出錯,出錯程式碼如下:
Warning: mssql_connect(): Unable to connect to server:
想想以前都是沒問題的,怎麼回事呢?後來去網上搜索,發現一篇文章,才發現原來伺服器是需要安裝mssql才能用php連接mssql的,本來新伺服器上我是不需要用到mssql的,但是現在沒辦法了,只能把擴充了,擴充了mssql之後就沒問題了。
擴充方法:
1、在c:/windows/php.ini檔案中找到
;extension=php_mssql.dll 把前面的分號去掉
#找到
;extension_dir = "./" 將擴充庫目錄改為php的函式庫目錄如:extension_dir = "c:/php/ext"
2、把php_mssql.dll檔案複製到c:/windows/system32/目錄下3、重啟iis。 下面是找到的一篇文章。 php設定:在php.ini檔案裡設定如下,找到 ;extension=php_mssql.dll 把前面的分號去掉 #找到#找到extension_dir = d:/extension/ 你的php.ini裡面可能不是d:/extension/ #改為在php安裝目錄下面的extensions目錄下面的php_mssql.dll,所在的所在的路徑,如果你沒有把它移到其他地方(假設你的php安裝路徑是d:/php) 就改成extension_dir=d:/php/extensions/ 然後重新啟動web伺服器這一點很容易做到,但是做完這樣的設定後還是連不上,錯誤的資訊如下:MS SQL Server 資料庫連線錯誤!請檢查資料庫主機變數設定是否正確!!!而主機的變數設定我是一遍一遍的檢查,那些設定是一點問題都沒有的,翻遍網頁,找到了下面的這點蛛絲馬跡:
php.com资料: I am trying to connect to SQL Server 2000 from PHP I bumped to following warning: Warning: mssql_connect(): Unable to connect to server: SERVER/Portal ....... on line 5 on line 5 there is: $db_connect = mssql_connect('SERVER/Portal', 'sa', 'my_passwd'); I did the following 1.enabled php_mssql.dll extension in PHP.ini 2.every dll is in proper place(System32 or PHP folder),including ntwdblib.dll I search lots of profile throught web ,but no one give me proper answer to resolve it. after a few hour ,I found the problem was caused by ntwdblib.dll ,which version is 7.00.839 ,when I replaced old ntwdblib.dll with the new ntwdblib.dll ,which version is 8.00.194 ,all problem are solved. We had some, read A LOT, of problems with MSSQL under Windows 2003. We had 2 the same windows, php, php-ini, everything machines but only one could connect. Unable to connect was the error message. Finnaly we checked the version of ntwdblib.dll and the one distributed with PHP was 7.00.... and the version of the one on the SQL Server install was 8.00.... so we copied this one in the php and apache dir and it worked.
以上是php連線mssql失敗怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!