0

I'm using Ubuntu 20.04 with PHP 7.4.3.

I have this PHP script to connect to Microsoft SQL Server 2005

<?php

function pdoOnLine() {
 global $pdo;

 $pdo = new PDO('dblib:host=10.10.10.10:1433;dbname=test', 'test', 'test', [
   PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
 ]);
}

try {
   pdoOnLine();  
} catch (\PDOException $e) {
 throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
?>

and I get the error

Fatal error: Uncaught PDOException: SQLSTATE[01002] Adaptive Server connection failed (10.10.10.10:1433) (severity 9)

How can I solve this problem?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 3
    FYI, SQL Server 2005 has been *completely* unsupported for **6 years**; you really shouldn't be using it any more. – Thom A Jul 01 '22 at 12:17
  • The same is with Microsoft SQL Server 2019 – Mario Rovelli Jul 01 '22 at 12:19
  • SQL Server 2019 isn't unsupported, @Mario ; it's still in mainstream support (and has over 2 years left of it). – Thom A Jul 01 '22 at 12:21
  • I mean i get the same error when i connect to Microsoft SQL Server 2019 – Mario Rovelli Jul 01 '22 at 12:25
  • Does this answer your question? [SQLSTATE\[01002\] Adaptive Server connection failed on PHP only, I can connect through CLI](https://stackoverflow.com/questions/56975051/sqlstate01002-adaptive-server-connection-failed-on-php-only-i-can-connect-thr) – Salketer Jul 01 '22 at 12:26

0 Answers0