問題描述
我使用的是通過 XAMPP 和 Microsoft SQL Server 2008 R2 (SQLEXPRESS) 安裝的 PHP 5.3.8 版.我已經(jīng)正確安裝了驅(qū)動(dòng)程序(我猜)并在 php.ini 中添加了正確的行(確切地說是 extension=php_pdo_sqlsrv_53_ts_vc9.dll).
我正在嘗試像這樣連接到服務(wù)器:
嘗試{$DBH = new PDO("mssql:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');} catch(PDOException $e) {echo $e->getMessage();}
我收到了找不到驅(qū)動(dòng)程序"的錯(cuò)誤消息,我已經(jīng)對(duì)其進(jìn)行了各種調(diào)整以解決該問題.我已經(jīng)嘗試了所有其他類型的驅(qū)動(dòng)程序,但這是唯一一個(gè) Apache 在啟動(dòng)時(shí)不給我錯(cuò)誤的驅(qū)動(dòng)程序.當(dāng)我運(yùn)行 phpinfo() 時(shí),除了 pdo_sqlsrv.log_severity 設(shè)置為 0 之外,pdo_sqlsrv 字段都是空白的.
我從
I'm using PHP Version 5.3.8 that was installed via XAMPP along with Microsoft SQL Server 2008 R2 (SQLEXPRESS). I have the drivers installed correctly (i guess) and have added the correct line into php.ini (extension=php_pdo_sqlsrv_53_ts_vc9.dll to be exact).
I'm trying to connect to the server like so:
try {
$DBH = new PDO("mssql:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');
} catch(PDOException $e) {
echo $e->getMessage();
}
I get the "could not find driver" error, and I've tweaked it all kinds of ways to solve the problem. I've tried all other kinds of drivers, but this is the only one that Apache doesn't give me an error on startup. When I run phpinfo(), the pdo_sqlsrv fields are all blank except pdo_sqlsrv.log_severity which is set to 0.
I DL'd my drivers from microsoft, and I've tried both 2.0 and 3.0
Any advice would be awesome!!
mssql
is the old way of doing it, sqlsrv
should be more appropriate! In fact the extension is called (extension=php_pdo_sqlsrv_53_ts_vc9.dll) as well ;)
try {
$DBH = new PDO("sqlsrv:Server=xxxx;Database=xxxx", 'xxxx', 'xxxx');
} catch (PDOException $e) {
echo $e->getMessage();
}
Hope this helps!
Source : http://php.net/manual/fr/ref.pdo-sqlsrv.connection.php
這篇關(guān)于MSSQL PDO 找不到驅(qū)動(dòng)程序的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!