MSSQL support for PHP with XAMPP

I need to setup this kind of environment:
OS: Windows 7 professional 64bit
web server: Apache
database: SQL server 2008 (or even 2012)
lang: PHP 5.6.35

I need to provide PHP connection to SQL server.
I downloaded XAMPP from this url:

I noticed that PHP is compiled without SQL Server support :

(from phpinfo):
 "--without-mssql" "--without-pdo-mssql"

How can I solve my issue?
Thank you very much
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you will need to buld PHP with MSSQL option
Refer below link it might help you.
mohan singhWeb developerCommented:
You can use ODBC Connection

If you want to use this odbc so first of all you need to install odbc driver then create your connection dsn with mssql server

Download this
Thank You
Armitage318Author Commented:
Hi, I used SQLSRV32 (according to my PHP version).
I extracted dll files in PHP extension dir, and I added to php.ini:


Open in new window

With this code:

 echo "<pre>";

Open in new window

I get:

    [0] => mysql
    [1] => sqlite
    [2] => sqlsrv

Open in new window

anyway, when I try to use such library, I get error:

FATAL ERROR: cannot load modules!

Thank you
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

mohan singhWeb developerCommented:
Restart your apache
check Your php and Apache version
Dave BaldwinFixer of ProblemsCommented:
For the SQLSRV extension to work, you also need the OBDC driver or the SQL Native Client.  It won't work without it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Armitage318Author Commented:
should I use 32 bit or 64 bit of OBDC driver?
My OS is Windows 7 64 bit, but I noticed that PHP is compiled for 32 bit architecture.

Thank you
Armitage318Author Commented:
I am using a PHP script to test if mssql or sqlsrv PHP driver is present.
Script returns "FATAL ERROR: cannot load modules"

I see that related php code is:

if (function_exists("sqlsrv_connect")) _SQLLIB("MS",true);

if (function_exists("mssql_connect"))  _SQLLIB("TDS",true);

if (_SQLLIB()===false)
  DIE("FATAL ERROR: cannot load modules!");

Open in new window

I confirm that I do see PDO_SQLSRV in phpinfo.. it sounds strange to me that there is no sqlsrv_connect function available.
Thank you again
Armitage318Author Commented:
I founded this in Apache's log:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\xampp\\php\\ext\\php_sqlsrv_56_ts.dl' - The specified procedure could not be found.\r\n in Unknown on line 0

Open in new window

I suspect that there is some mismatch in version.
I am using PHP version shipped with XAMPP (5.6.35); I don't know which version is PHP driver downloaded from Microsoft, they said only "5.6"

driver file: php_sqlsrv_56_ts.dll  , php_pdo_sqlsrv_56_ts.dll
PHP version: 5.6
Thread safe: yes
Use with PHP .dll: php5ts.dll

Open in new window


Thank you again..
Armitage318Author Commented:
Ok, I simpy renamed php_sqlsrv_56_ts.dl to php5ts.dll and now I get a different message:

Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][Driver Manager ODBC] Nome origine dati non trovato e driver predefinito non specificato. [message] => [Microsoft][Driver Manager ODBC] Nome origine dati non trovato e driver predefinito non specificato. ) ) Could not connect to database: 1

Open in new window

So, Dave Baldwin was right, I need the OBDC driver ..
I will update you shortly
Armitage318Author Commented:
I also needed to rename php_sqlsrv_56_ts.dll to php5ts.dll in c:\xampp\php\ext
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.