How to connect to mssql using pdo through PHP and Linux?
The PDO mssql driver is no more, use sqlsrv
(under php windows) or dblib
(under php linux)
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.
Try
$dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");$hostname may need to be configured as either...$hostname.':'.$port;
OR
$hostname.','.$port;