日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php sqlserver扩展,PHP---连接sqlserver扩展配置

發布時間:2025/3/19 php 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php sqlserver扩展,PHP---连接sqlserver扩展配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本人環境Apache:2.2.21 php:5.3.10 操作系統windows xp service pack 3

使用的是Microsoft Drivers for PHP for SQL Server的擴展包做連接。

1.下載Microsoft Drivers for PHP for SQL Server 擴展包?它分為2.0和3.0版

本。(本人使用的是2.0版本)

這個擴展包對電腦的操作系統有要求,對應的系統使用對應的版本。

3.0?所支持的操作系統

Windows Server 2008 R2 SP1

Windows Vista SP2

Windows Server 2008 SP2

Windows 7 SP1

2.0 所支持的操作系統

Windows Server 2003 Service Pack 1

Windows XP Service Pack 3

Windows Vista Service Pack 1 or later

Windows Server 2008

Windows Server 2008 R2

Windows 7

所以本次實例使用的是 2.0?里面php_sqlsrv_53_ts_vc9.dll 擴展

;

2.將php_sqlsrv_53_ts_vc9.dll文件復制到php的擴展文件夾 (一般的都在

php/ext文件夾下面);

3.將此php_sqlsrv_53_ts_vc9.dll文件拷貝到系統所在盤的system32中;

4.打開php.ini文件,在extension=php_mysql.dll 下面一行添加

extension=php_sqlsrv_53_ts_vc9.dll?之后重啟apache。

5.測試代碼

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

$serverName = "127.0.0.1";

$uid = "sa";

$pwd = "000";

$db?= "php555";

$connectionInfo = array(

"UID"=$uid,"PWD"=$pwd,"Database"=$db

);

$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn === false )

{

echo "Unable to connect.";

die(var_dump( sqlsrv_errors(), true));

}else{

echo "sqlserver連接成功!!!";

}

6.運行上邊代碼會提示您以下內容

Unable to connect.

array(2) { [0]=> array(6) { [0]=> string(5) “IMSSP”

["SQLSTATE"]=>

string(5) “IMSSP” [1]=> int(-49) ["code"]=> int(-49) [2]=>

string(390)

“This extension requires either the Microsoft SQL Server 2008

Native

Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native

Client

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:

["message"]=>

string

(390) “This extension requires either the Microsoft SQL Server

2008

Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2

Native

Client 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: } [1]=>

array(6) {

[0]=> string(5) “IM002″ ["SQLSTATE"]=> string(5) “IM002″

[1]=> int(0)

["code"]=> int(0) [2]=> string(71) “[Microsoft][ODBC 驅動程序管理器]

發現數據源名稱并且未指定默認驅動程序” ["message"]=> string(71)

“[Microsoft][ODBC 驅動程序管理器] 未發現數據源名稱并且未指定默認驅動程

序” } } bool(true)

7.點擊 這個鏈接 進入下載驅

動程序包就可以了,X86 Package(sqlncli.msi) 。安裝的時候有可能某些軟件會影響到安裝,導致安裝失敗,

建議您關掉沒用的程序。

8.之后再運行第5步代碼; 提示:”sqlserver連接成功!!!” 。

9.具體的sqlsrv的函數就不做介紹了 在擴展包里面有手冊,手冊里面有詳細介紹。

(轉載請注明出處,謝謝)

總結

以上是生活随笔為你收集整理的php sqlserver扩展,PHP---连接sqlserver扩展配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。