此扩展要求用于SQL Server的Microsoft ODBC驱动程序11与SQL Server通信 [英] This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server

查看:1639
本文介绍了此扩展要求用于SQL Server的Microsoft ODBC驱动程序11与SQL Server通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经在Microsoft上下载了sqlsrv ...

ALready downloaded the sqlsrv on microsoft...

和我的phpinfo()

and on my phpinfo()

仍然出现这样的错误.

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驱动程序.

Apart of the pdo_sqlsrv extension, you also need to have the ODBC 11 driver installed on your machine.

您可以在以下位置之一获得它:

You can get it at one of these locations:

  • https://www.microsoft.com/en-us/download/details.aspx?id=36434
  • https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

这篇关于此扩展要求用于SQL Server的Microsoft ODBC驱动程序11与SQL Server通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆