0

I am restricted to use only PHP mssql module to use with MS Azure SQL Server.

I am able to maintain connection by adding: ~/.freetds.conf:

[aftermath]
    database = mydatabase
    host = myhostname.database.windows.net
    port = 1433
    tds version = 8.0

My code in PHP

$myServer = "aftermath"
$myUser = username@hostname
$myPass = obviously_my_pass

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

But when I check which database is selected it returns:

 master

instead of my desired database which is specified in my freetds.conf file

Module sqlsrv is not installed on my hosting and I do not have rights to install it.

Can you tell me how can I resolve this issue?

Zhorov
  • 28,486
  • 6
  • 27
  • 52
  • Possible duplicate of [PHP mssql\_connect() to Azure Database](https://stackoverflow.com/questions/19249696/php-mssql-connect-to-azure-database) – Dave C Nov 16 '18 at 03:44
  • Answer presented in that topic is using sqlsrv function from module not installed on my hosting. I am unable to use it – Aftermathx25 Nov 16 '18 at 15:34
  • See this: https://stackoverflow.com/questions/18452262/how-to-query-in-a-specific-database-on-azure – Zhorov Nov 20 '18 at 09:53
  • sqlsrv is deprecated, try odbc: https://browse-tutorials.com/tutorial/php-connect-azure-db – ram4nd Feb 11 '20 at 11:54

0 Answers0