skip to Main Content

I am having a very frustrating problem connecting to SQL Anywhere 17 from PHP 7.4.5. The OS is CentOS 7.9. I have installed the SQL Anywhere client v17. There is no Apache or web-server, PHP is in COMMAND LINE mode only!

I am explicitly loading the 64-bit extension for SQL Anywhere. "libdbcapi.so" is also loaded.
extension=/usr/include/php/ext/php-7.4.0_sqlanywhere.so ( -> php-7.4.0_sqlanywhere.so.1)

My connection string is as follows:

$connString = "Uid=".$username.";Pwd=".$password.";CommLinks=tcpip(host‌​=".$server.";Port=".$port.")";

And I am doing the following:

<?php

$server = "192.168.56.105";
$port = "2638";
$username = "username";
$password = "********";

if( ! extension_loaded('sqlanywhere') ){
    print("SQL ANYWHRE not available.n");
} else {
    print("SQL ANYWHERE extension loaded.n");
}

$connString = "Uid=".$username.";Pwd=".$password.";CommLinks=tcpip(host‌​=".$server.";Port=".$port.")";

echo "Connecting to SQL Anywhere with: '$connString'n";

$conn = sasql_connect($connString);

if(!$conn){
    echo "Error connecting.";
} else {
    echo "Connected.";
    sasql_disconnect($conn);
}

?>

I keep getting the following error though:

PHP Warning: sasql_connect(): SQLAnywhere: [-832] Connection error: Error in TCPIP port options in /root/scripts/bcliqx/companies_pull.php on line XX

I have tried

$connString = "Uid=".$username.";Pwd=".$password.";Server=".$serverName.";host‌​=".$server.":".$port.")";
$connString = "Uid=".$username.";Pwd=".$password.";host‌​=".$server.":".$port.")";
$connString = "Uid=".$username.";Pwd=".$password.";host‌​=".$server.";port=".$port;
$connString = "Uid=".$username.";Pwd=".$password.";CommLinks=tcpip(host‌​=".$server.":".$port.")";
$connString = "Uid=".$username.";Pwd=".$password.";CommLinks=tcpip(host‌​=".$server.";Port=".$port.")";

And I keep getting the above error or this one:

PHP Warning: sasql_connect(): SQLAnywhere: [-95] Parse error: Invalid or missing keyword near ‘host‌​’ in /root/scripts/bcliqx/companies_pull.php on line XX

The actual username and password contain ONLY alpha-numeric characters A-Za-z0-9 and are not very long (8 chars, 12 chars respectively).

I am rapidly losing my sanity. What am I doing wrong?? The server is there. If I open the server & port using different tools, it answers, so connectivity is not the issue.

EDIT: Want to add that the problem happens on a cleanly installed CentOS 7.9 server as well as an older server.

2

Answers


  1. Chosen as BEST ANSWER

    The solution came from a former colleague who suggested I change the string to the following:

    $connString = "UID=".$username.";PWD=".$password.";ENG=IQX;LINKS=tcpip(HOST=$server;DoBroadcast=NONE;PORT=$port)";
    

    This works. But this does not:

    $connString = "UID=".$username.";PWD=".$password.";ENG=IQX;LINKS=tcpip(HOST=".$server.";DoBroadcast=NONE;PORT=$port)";
    

    The second option works with a SERVERNAME as long as it contains no ".", e.g. $server = "sa17svr" will work, but $server="sa17svr.domain.com" won't.


  2. you need for the PHP module has a cmdline tool called dbping included.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search