简体   繁体   中英

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?

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM