I've been trying to connect to my Azure SQL database using PHP 7.1. I've been following Microsoft's instructions so I'm using the iis express. After browsing and following the directions from posts like "Call to undefined function sqlsrv_connect()" when trying to connect to Azure DB from PHP and Cannot Call function sqlsrv_connect(), I still cannot connect.
<?php
$serverName = "database_name.database.windows.net";
$connectionOptions = array("Database" => "database_name");
try {
$conn = sqlsrv_connect($serverName, $connectionOptions);
} catch (Exception $e) {
print_r($e);
}
?>
Here are the solutions I've tried:
- Installed all the necessary SQL drivers
- Reconfigured the php.ini file with the extensions and correct extension path
- Ran PHP as an administrator from the PHP folder and also from another folder using its %PATH%
- Restarted several times
- Connected successfully to the database from the CMD line
This is my first time using PHP to connect to a remote SQL server so any help would be greatly appreciated.