So I am writting some code so I can access a Microsft SQL Server. The code I am writting is in a Centos 7 machine. I've installed the php mysql and mssql packages but when I run
echo "<pre>", print_r(PDO::getAvailableDrivers()), "</pre>";
I get the following output:
Array
(
[0] => mysql
[1] => pgsql
[2] => sqlite
)
I've restarted the lampp and still got the same result.
I've also edited php.ini
to include extension=php_mssql.so
, and restarted lampp and still got the same output.
When I run the pdo script:
try
{
$con = new PDO("dblib:host=".$db_addr.";dbname=".$db_name.";charset=utf8", '".$db_usr."', '".$db_pass."');
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "ERROR: ". $e->getMessage();
die();
}
I always get:
ERROR: could not find driver
I relalise that this needs to be configured in the php.ini
, but the the drivers that are output are commented out of php.ini
, hence I am quite confused.
Can someone guide me in the proper direction?
EDIT: I've followed @jap1968 answer in here, but I got stuck at where I am now.