sql server - PHP PDO could'nt not find driver


I'm getting error ofPDO cannot find driver using PDO in environment. I'm using xamp on a Mac.

I had got to know the problem and I've installed freetds using homebrew install, and had successfully connected to the azure mssql server using below command

tsql -H 234fddfg.database.windows.net -p 1433 -U dbuser -P db123!

but I don't know what to do next.

I've tried below php code but I'm still getting the same error.

$dbh = new PDO("sqlsrv:Server=localhost;Database=mydb", "dbuser", "db123");



Driver for Microsoft SQL Server for PHP is needed to be installed for this.

Follow this link: https://www.microsoft.com/en-in/download/details.aspx?id=20098

Perform the following steps to download and install the Microsoft Drivers for PHP for SQL Server (example below for 3.2 version):
1. Download SQLSRV32.EXE to a temporary directory
3. When prompted, enter the path to the PHP extensions directory
4. After extracting the files, read the Installation section of the SQLSRV32_Readme.htm file for next steps

Now just add the following line to your PHP.ini (this is for the non-thread safe version of PHP, which you are most likely using when you have installed PHP to use IIS FastCGI, which we recommend):


And Restart server



Have you installed PDO_DBLIB, it seems that in OSX, we need to leverage PDO_DBLIB as the pdo driver connecting to MS SQL, e.g.

$pdo = new PDO("dblib:host=$dbhost;dbname=$dbname", "$dbuser","$dbpwd");

you can refer to Configure PHP environment on Mac to connect to SQL Server using PDO interface for more information.

People are also looking for solutions to the problem: Fatal PHP error with dompdf in drupal 7 site


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.