【发布时间】:2015-12-21 17:23:40
【问题描述】:
已经在 microsoft 上下载了 sqlsrv...
在我的 phpinfo() 上
在php.ini 和C:\wamp\bin\apache\apache2.4.9\bin 和C:\wamp\bin\php\php5.5.12 上启用
仍然出现这样的错误。
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);
【问题讨论】:
-
“驱动程序 11”。你检查过你实际安装的版本吗?仅仅拥有一个 sqlserver 驱动程序没有任何意义。
-
@MarcB 你是什么意思?在哪里检查?
标签: php sql-server