PHP PDO sqlsrv Undefined class constant SQLSRV_ENCODING_UTF8 PHP PDO sqlsrv Undefined class constant SQLSRV_ENCODING_UTF8 codeigniter codeigniter

PHP PDO sqlsrv Undefined class constant SQLSRV_ENCODING_UTF8


You likely have the wrong PDO driver in your PHP install. I run PHP/CodeIgniter on several Windows servers, and have run into problems with the wrong drivers when getting things initially setup.

Since you are on PHP 5.6, you need to make sure the php_pdo_sqlsrv_56_ts.dll OR php_pdo_sqlsrv_56_nts.dll driver is in the PHP /ext/ directory. Then, in your php.ini file, you will need to make sure that both of these extensions are uncommented:

extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll

Once those two are uncommented, make sure the other references to the SQL Server drivers are commented out. If that doesn't help, here is another article to check: Xampp MS SQL server PHP 5.6.

After adjusting the php.ini file, remember to restart the site via IIS.


For people searching for a solution for this error, I fixed it by specifying a default TCP port in SQL Server Configuration Manager.