Unable to connect to mssql database using php file in XAMPP

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Unable to connect to mssql database using php file in XAMPP

Postby pavi_elex » 15. January 2015 08:55

I am facing a problem in XAMPP. I am using UBUNTU operating system (or sometimes CentOS). I have installed XAMPP 1.8.3-4 (before XAMPP 1.8.1 ) in both Operating systems (as /opt/lampp). I am not able to connect to mssql database using php file in any version of xampp.
I have written following code in a php file.
Code: Select all
   $con = new PDO("dblib:dbname=dbname;host=hostname", 'username', 'password');
echo "Yes... Connected";
}catch(PDOException $e){
   echo 'Failed to connect to database: ' . $e->getMessage() . "\n";

I have saved this file as connection.php inside htdocs. Now when I run http://localhost/connection.php in browser
It gives me following error.
Code: Select all
Failed to connect to database: could not find driver

When I checked my phpinfo.php, I found the PDO driver "dblib" is missing under PDO module. Please see PDO section of XAMPP's phpinfo
I think this is the problem that's why I am not able to connect to ms-sql database. I do not know, how to install dblib driver under pdo module.

We have installed individual apache, mysql, php, pgsql on another ubuntu system using command line (sudo apt-get install package-name) and we are able to connect to ms-sql database using same file.
The only difference between phpinfo of other ubuntu system and mine is the dblib PDO driver under PDO module. Other system has dblib driver but I do not have. Installing individual packages, php5-sybase gives dblib driver but I think this is missing in XAMPP.
This is the PDO section of other ubuntu system's phpinfo

Please give me solution to connect to ms-sql database.

Posts: 2
Joined: 15. January 2015 07:51
Operating System: ubuntu / centos

Re: Unable to connect to mssql database using php file in XA

Postby Beltran » 15. January 2015 09:50

XAMPP ships the mssql module but it does not include the PDO driver for MSSQL. We will check if we can enable it for next versions. Thanks for reporting it.
User avatar
Posts: 153
Joined: 22. March 2013 12:29
Operating System: Windows, Linux, OS X

Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 6 guests