从 PHP 中的 LAMP localhost 访问 Azure SQL 数据库
Access Azure SQL Database from LAMP localhost in PHP
我想使用 PHP-脚本连接到 Azure SQL 数据库。我使用 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));
}
?>
当然我检查了 Azure 上的防火墙规则。我允许我的 IP 访问服务器。
但我收到错误消息:
GET http://localhost/Ionic/test.php in the web console.
我做错了什么?
感谢您的帮助!
函数 sqlsrv_connect
需要 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。
我想使用 PHP-脚本连接到 Azure SQL 数据库。我使用 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));
}
?>
当然我检查了 Azure 上的防火墙规则。我允许我的 IP 访问服务器。 但我收到错误消息:
GET http://localhost/Ionic/test.php in the web console.
我做错了什么? 感谢您的帮助!
函数 sqlsrv_connect
需要 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。