I need to connect to an Azure SQL DB from an external PHP app on shared cPanel hosting.
My host has enabled mssql_connect but wont enable MS’s recommended sqlsrv_connect in the shared environment.
I have whitelisted the webserver IP in Azure’s Portal, and whitelisted the DB address in cPanel.
The test script seems to try to connect, but cant. No error information is provided: http://app.hivve.com.au/api/
PHP is:
$db_server = "cjweb.database.windows.net:1433"; // update me
$db_username = "username";
$db_password = "password";
$conn = mssql_connect($db_server, $db_username, $db_password);
print_r(mssql_get_last_message());
Has anyone else been down this road? My host wont provide anymore assistance so Im stuck.
2
Answers
Could you please try to connect as shown below? Please look at the user name.
Add [aftermath] on the ~/.freetds.conf:
What I found in Azure SQL document Quickstart: Use PHP to query an Azure SQL database that maybe you have lost the "UID" agrument.
You can first test Alberto Morillo’s code.
Hope this helps.