Search code examples
phpsql-servermacosazuremamp

can't connect php to azure ms sql server database


Does anyone know how to connect a php website to ms sql server database on azure? Currently I'm using OSX Sierra 10.12.4, MAMP ver 4.1.1, and php7.1.1.

$serverName = "your_server.database.windows.net";
$connectionOptions = array(
"Database" => "your_database",
"Uid" => "your_username",
"PWD" => "your_password"
);

$conn = sqlsrv_connect($serverName, $connectionOptions);

Im getting the error: Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect()

does anyone know what packages I need to install?


Solution

  • It seems that you haven't installed Microsoft PHP drivers for SQL Server on your machine. The step by step installation instructions can be found in the Readme file: https://github.com/Microsoft/msphpsql

    Mac OS X

    brew tap microsoft/mssql-preview https://github.com/Microsoft/homebrew-mssql-preview
    brew update
    brew install msodbcsql
    brew install mssql-tools
    brew install autoconf