I am trying to connect to SQL Server using PHP PDO however it keeps giving me error. And, i already have file php_pdo_sqlsrv_53nts.dll
in following directory xampp->php
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\xampp\htdocs\config.php:35 Stack trace: #0 C:\xampp\htdocs\config.php(35): PDO->__construct('sqlsrv:server=C...', 'username...', 'pass') #1 {main} thrown in C:\xampp\htdocs\config.php on line 35
Here is my PHP code:
<?php
$serverName ="serverName";
$dbName="databaseName";
$username="userName";
$password="passWrord";
$connection = new PDO("sqlsrv:server=$serverName ; Database=$dbName", "$username", "$password");
if( $connection )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
?>
Is there something wrong i am doing? Appreciated.