1

CentOS7. I have installed

yum install freetds-bin

and

yum install php5-mssql

PDO drivers in phpinfo: dblib, mysql, sqlite

File with connection:

try {
    $hostname = "xxx.xxx.xxx.xx";
    $port = 1443;
    $dbname = "MyName";
    $username = "test";
    $pw = "123456";
    $dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
}

This page is very long running, and at the end shows error 500.

An error in the connection in this file? Or is the remote access to the SQL Server opened incorrectly on the MSSQL side? How to understand which side of the problem?

user3798618
  • 758
  • 1
  • 7
  • 12
  • You could try, 1) Change to `$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname",$username,$pw);` (removed "" from `$username` and `$pw`) 2) Try to change `$hostname` to `localhost` . If nothing happens, make sure somehow that all modules are properly installed. – Antonios Tsimourtos Apr 04 '17 at 11:07
  • @Antonis Tsimourtos 1. The connection has changed. Nothing has changed. 2. I can not specify localhost, because the database is on another server. But I tried. Answer: Failed to get DB handle: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (localhost:1443) – user3798618 Apr 04 '17 at 11:13
  • Actually, the error message you get is related to this question: http://stackoverflow.com/questions/8511369/adaptive-server-is-unavailable-or-does-not-exist-error-connecting-to-sql-serve – Bud Damyanov Apr 04 '17 at 11:19
  • Possible duplicate of ["Adaptive Server is unavailable or does not exist" error connecting to SQL Server from PHP](http://stackoverflow.com/questions/8511369/adaptive-server-is-unavailable-or-does-not-exist-error-connecting-to-sql-serve) – Bud Damyanov Apr 04 '17 at 11:20
  • @bodi0 Thanks! https://image.ibb.co/eQQCmF/u1.jpg Does this message mean that everything is good? – user3798618 Apr 04 '17 at 12:13
  • @user3798618 - Hell yeah. – Bud Damyanov Apr 04 '17 at 12:27
  • @bodi0 But how to do this not in the console but in a PHP file? – user3798618 Apr 04 '17 at 13:32

0 Answers0