ALready downloaded the sqlsrv on microsoft...
and on my phpinfo()
enabled on php.ini
on both C:wampinapacheapache2.4.9in
and C:wampinphpphp5.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() . "
";
exit;
}
$stmt = $dbh->prepare("select top 5 from teams");
$stmt->execute();
while ($row = $stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…