Can't connect my php code to sql server db

#1

My site is hosting on windows server and I’m using php 7.3.4 and already have installed drivers. Using these two extensions in my php.ini file:
extension=php_sqlsrv_73_nts_x64
extension=php_pdo_sqlsrv_73_nts_x64

The code I’m using is bellow. I’ve tried so many ways but none of them was success.
Please can someone give me a hand

$serverName = ip_addr_of_server;
    $database = name_of_db;
    $uid = user_name;
    $pwd = password;
    try {
        $dbDB = new PDO(
            "sqlsrv:Server=$serverName;Database=$database",
            $uid,
            $pwd
        );
        $dbDB->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
    }
#2

And the issue is what, you can’t connect?

#3

Yes, I can’t connect to the server… doesn’t display data

#4

Are you seeing any errors?

#5

This shows it in the console -> Failed to load resource: the server responded with a status of 502 (Bad Gateway)