[英]This extension requires the Microsoft ODBC Driver 11 for SQL Server in PHP
[英]This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server
已經在 Microsoft 上下載了 sqlsrv ...
在我的 phpinfo() 上
在C:\wamp\bin\apache\apache2.4.9\bin
和C:\wamp\bin\php\php5.5.12
的php.ini
上啟用
仍然有這樣的錯誤。
Failed to get DB handle: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712
我的代碼是
try {
$dbh = new PDO ("sqlsrv:Server=$host;Database=$db","$user","$pass");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
$stmt = $dbh->prepare("select top 5 from teams");
$stmt->execute();
while ($row = $stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
除了pdo_sqlsrv
擴展之外,您還需要在計算機上安裝 ODBC 11 驅動程序。
您可以在以下位置之一獲取它:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.