I would like to connect to by Azure SQL database by using a PHP-Script. I execute the following script by using LAMP:
<?php
$serverName = "tcp:***.database.windows.net, 1433";
$connectionOptions = array("Database" => "TryMe",
"UID" => "***@serverID",
"PWD" => "***");
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn === false)
{
die(print_r(sqlsrv_errors(), true));
}
?>
Of course I checked the firewall rules on Azure. I allowed my IP to access the server. But I'm getting the error message:
GET http://localhost/Ionic/test.php in the web console.
What I'm doing wrong? Thanks for your help!
The function sqlsrv_connect
requires the Microsoft Drivers for PHP for SQL Server which is only enabled in Windows system. As you are working in LAMP environment, you can try to use ODBC extension and Microsoft's SQL Server ODBC Driver for Linux.