msphpsql: [Ubuntu 16.04] [PHP 7.0] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)
I am trying to connect with php 7.0 after install with:
sudo su
wget https://gallery.technet.microsoft.com/ODBC-Driver-13-for-Ubuntu-b87369f0/file/154097/2/installodbc.sh
sh installodbc.sh
$ sqlcmd -H xxx.xxx.xxx.xxx:xxxx -d MYTABLE -U MYUSER -P MYPASS
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x274D.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
$ odbcinst -q -d -n "ODBC Driver 13 for SQL Server"
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
Threading=1
UsageCount=1
cat test.php
<?php
$dbo = new PDO('dblib:host=xxx.xxx.xxx.xxx;dbname=MYTABLE;port=xxxx', 'MYUSER', 'MYPASS');
var_dump($dbo);
$ php7.0 test.php
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9) in test.php:3
Stack trace:
#0 test.php(3): PDO->__construct('dblib:host=xxx.xx...', 'MYUSER', 'MYPASS')
#1 {main}
thrown in test.php on line 3
Connecting with tsql works fine:
$ LC_ALL=en_US.UTF-8 tsql -U MYUSER -H xxx.xxx.xxx.xxx -p xxxx -P MYPASS
$ LC_ALL=en_US.UTF-8 tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
I cannot even install php-pdodblib from PECL because it is not supported PHP 7.0
$ sudo pecl install PDO_DBLIB pear/PDO_DBLIB requires PHP (version >= 5.0.3, version <= 6.0.0), installed version is 7.0.9-1+deb.sury.org~xenial+1 No valid packages found install failed
I came here from this stackoverflow post. There are really support for PHP 7.0?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 25 (7 by maintainers)
Clean up your INIs and use the NTS (non thread safe) version of the extension
/etc/php/7.0/mods-available/sqlsrv.inicontains/etc/php/7.0/mods-available/pdo_sqlsrv.inicontainsEnable the PHP extensions
Make sure that PHP odbc extension is installed and enabled