Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server

Viewed 1948

I am trying to connect from Linux Centos7 with Cpanel on, to a remote SQL Server.

I have installed pdo_sqlsrv, its there in Php Info.

I have installed ODBC Driver 11 for SQL Server, as per this output:

[root@myserver ~]# odbcinst -q -d -n "ODBC Driver 11 for SQL Server"
[ODBC Driver 11 for SQL Server]
Description=Microsoft ODBC Driver 11 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
Threading=1
UsageCount=1

But my PHP script shows:

Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 in /home/mysite/public_html/dev/stock-import.php:17 Stack trace: #0 /home/mysite/public_html/dev/stock-import.php(17): PDO->__construct('sqlsrv:Server=1...', 'myusername', 'mypassword') #1 {main} thrown in /home/mysite/public_html/dev/stock-import.php on line 17

So its installed.

Any ideas?

PHP code is:

$dbh = new PDO( "sqlsrv:Server=$server:$port", $user, $pass );

Update: Actually, the error I used to get before installing ODBC Driver 11 for SQL Server said to install ODBC Driver 11 for SQL Server, so specifically version 11, but after installing version 11, the error does not show the version.

Update: If I use odbc_connect I get:

odbc_connect(): SQL error: [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired, SQL state S1T00 in SQLConnect

Update: It’s working now. I’ve uninstalled the ODBC Manager 2.3.0 and Driver 11 and installed ODBC Manager 2.3.7 and Driver 17 and it’s working now.

0 Answers
Related