I am trying to fix an error while trying to connect to MSSQL using PHP on my windows server running IIS.
The error that I am getting is - ODBC error.
Sorry can't copy the error text here and hence the image.
I have PHP 5.6 configured and working. The necessary dll files are there in the php extensions folder. They're also configured in the ini file.
Extensions used for the MSSQL connection are:
extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll
I am using the below sample code to connect to the mssql db:
<?php
$servername = "ServerName";
$conninfo = array ("Database" => "DBName", "UID" => "UserName" , "PWD" => "Password");
$conn = sqlsrv_connect($servername, $conninfo);
if($conn){
echo "Connection Established."
}else{
die(print_r(sqlsrv_errors(), true));
}
?>
The connection always gives me the error shown in the image attached.
I have been stuck with this for quite a few days and haven't been able to get this resolved.
Any help would be greatly appreciated.