When trying to connect to a SQLServer with sybase_connect(), I get the following errors:
From command line: $> php test.php
Fatal error: Uncaught Error: Call to undefined function sybase_connect() in test.php:7
Running the script through XAMPP:
Warning: sybase_connect(): Sybase: Client message: Unable to connect: Adaptive Server is unavailable or does not exist (severity 78) in test.php on line 7
Warning: sybase_connect(): Sybase: Unable to connect in test.php on line 7
Fatal error: Call to undefined function error() in test.php on line 7
Here's my code:
<?php
$server = 'server.domain.com';
$username = 'user';
$password = 'pwd';
$sqlconnect = sybase_connect($server, $username, $password, 'UTF-8') or error('connect');
I'm running XAMPP on Mac OS, PHP 5.6.
I've tried connecting to the server through tsql on command line and it actually works (with and without specifying the port):
tsql -S server.domain.com -U user
tsql -S server.domain.com -U user -p 1433
I've tried activating the extension for sybase on php.ini but still getting the same error:
extension=php_sybase_ct.dll
I've also tried a number of random things from stackoverflow answers but, to be honest, I'm completely lost here.
AFAIK, the sybase*
functions could only connect to older versions of SQL Server, and have been removed in PHP 7.0, which will soon be the only secure version available.
I would advise using PHP's sqlsrv_connect()
:
https://www.php.net/manual/en/function.sqlsrv-connect.php
...or PDO: https://www.php.net/manual/en/pdo.construct.php
Good luck!