I am running on:
- Windows Server 2016 64-bit
- MSSQL Server 2016 on the same server
- PHP 7.1
- IIS 10
I have:
- Made sure I can connect to my SQL using the credentials supplied in the codes below.
- Installed SQL Server Driver from for PHP from Microsoft, and chose SQLSRV40
- Added extension=php_sqlsrv_7_nts_x64.dll and extension=php_pdo_sqlsrv_7_nts_x64.dll to /ext folder.
- edited my php.ini and added extension=php_sqlsrv_7_nts_x64.dll and extension=php_pdo_sqlsrv_7_nts_x64.dll and restarted the server.
The following are my code to establish connection:
$connectionInfo = array( "Database"=>$db, "UID"=>$username, "PWD"=>$password);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{ //Will not execute. As such, I have no idea what error(s) am I getting
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
Executing phpinfo() does not show the sqlsrv. However, executing the following code will display a YES.
echo "Did it load? " . extension_loaded('php_sqlsrv_7_nts_x64.dll') ? "YES" : "NO";
I have worked on this for 2 days, and have followed many forums suggestions, and I have no idea what to try anymore. Would appreciate any advise from you experts! :)
Update 1:
I modified the codes below, and it shows a NO.
echo "Did it load? " . (extension_loaded('sqlsrv') ? "YES" : "NO");
echo "Did it load? " . (extension_loaded('pdo_sqlsrv') ? "YES" : "NO");
I don't understand why is it not installed correctly where the dll has already been put inside the extension folder, and specified inside php.ini as I stated earlier.