How to connect to mssql using pdo through PHP and Linux?
Try
$dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");
$hostname may need to be configured as either...
$hostname.':'.$port;
OR
$hostname.','.$port;
The PDO mssql driver is no more, use sqlsrv
(under php windows) or dblib
(under php linux)
http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
http://www.php.net/manual/en/ref.pdo-dblib.php
I am running Ubuntu 14.04. Trying to connect to MSSQL I got "Uncaught exception 'PDOException' with message 'could not find driver'". It seems that I was missing the dblib/sybase PHP extension.
I had to run:
sudo apt-get install php5-sybase freetds-common libsybdb5 \
&& sudo apache2ctl restart
Works fine now.