I am having trouble in Connecting to SQL Server remotely from PHP/Ubuntu 20.
Currently My PHP version is PHP7.4.I used this document to install the ODBC Driver
https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#installing-on-ubuntu (I have replaced the php version to 7.4 wherever it was 8.0).
Restarted the server and checked PHP Info. Seems its installed check screenshot
Now I am trying to connect to SQL Server. The SQL Server Access was given in IP, Username and Password. I am able to connect to database from HeidiSQL tool.
When I connect through PHP Code:
$conn = new PDO("sqlsrv:Server=". $serverName .";Database=". $databaseName, $uid, $pwd);
or
$serverName = "xxx.xxx.xxx.xxx";
$connectionOptions = array(
"database" => "<mydbname>",
"uid" => "<dbusername>",
"pwd" => "<dbpass>"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
both given me error:
SQLSTATE: 08001
Code: 10054
Message: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746
Can anyone help in I don't know what I should follow. Is something I need to check on installation side, I mean on Ubuntu server or I should ask to SQL Server provider if they need to do something on their end.

