ALready downloaded the sqlsrv on microsoft...
and on my phpinfo()
enabled on php.ini
on both C:\wamp\bin\apache\apache2.4.9\bin
and C:\wamp\bin\php\php5.5.12
and still got error like this.
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
and my code is
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);
Microsoft ODBC Driver for SQL Server (MSODBCSQL) Driver history for Microsoft SQL Server recommends this driver in preference to "SQL Server" and "SQL Server Native Client" for ODBC.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With