连接到Mac上的Microsoft SQL Server PHP

连接到Mac上的Microsoft SQL Server PHP,php,sql-server,macos,Php,Sql Server,Macos,我有一本约塞米蒂的Macbook。我从苹果商店下载了一个应用程序,试图运行PHP代码。我想连接到Microsoft SQL Server,代码如下: $serverName = "astidbs"; $connectionInfo = array( "Database"=>"generale1", "UID"=>"xxxx", "PWD"=>"xxxx"); $conn = sqlsrv_connect($serverName, $connectionInfo); if( $

我有一本约塞米蒂的Macbook。我从苹果商店下载了一个应用程序,试图运行PHP代码。我想连接到Microsoft SQL Server,代码如下:

$serverName = "astidbs";
$connectionInfo = array( "Database"=>"generale1", "UID"=>"xxxx", "PWD"=>"xxxx");
$conn = sqlsrv_connect($serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
我不明白这是否是一个应用程序问题,所以我在一个在线测试仪上尝试了该代码,但也不起作用。错误相同,但没有路径。似乎没有指定调用的lib,所以我在谷歌上搜索了如何安装它,但我无法解决这个问题。有人有解决方案吗?

请尝试以下方法:

<?php
$myServer = "astidbs";
$myUser = "your_name";
$myPass = "your_password";
$myDB = "examples"; 

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer"); 

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB"); 

//close the connection
mssql_close($dbhandle);
?>

不,它不起作用。问题是相同的:调用未定义的函数mssql_connect()。我已经安装了freetds并对其进行了配置,但没有任何效果
<?php
$myServer = "astidbs";
$myUser = "your_name";
$myPass = "your_password";
$myDB = "examples"; 

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer"); 

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB"); 

//close the connection
mssql_close($dbhandle);
?>