How to Connect to a Microsoft SQL Database using PDO?


I’m trying to access a Microsoft SQL database using PDO, but I’m getting the error message “Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’”.
From what I’ve found, I need to add the php_pdo_sqlsrv_56_nts.dll to my php5 directory and then add it to my php.ini file. however I have not been able to find a way to move the dll into the directory where the rest of the php .dll’s are stored. Is there an easy way for me to move this dll into place and get this working?
Or is there a different way that I should be doing this?

Thanks in advance for any help!


have you used this command to see if sqlsrv is installed

<?php print_r(PDO::getAvailableDrivers()); ?>


Current drivers installed are: dblib, mysql, pgsql, and sqlite

But not sqlsrv.


you’re databse SQL SRVR is stored with or an external service?
Link of the driver for Ubuntu :


After, you can look this :
Maybe can help you. Have a Good Luck !


Hi thank you so much for your post! Now it may be that I just have no experience with linux and therefore this is a simple problem, but I don’t know what directory php is install on in c9 and I can’t figure out how to change directory (or which directory it is in) to uninstall libodbc1 as required in your last post in installing the driver.

How do I cd to the directory that has php installed?