0
votes

Environment:

  • Apache 2.2.9
  • PHP 5.4.37
  • freetds 0.91
  • SQL Server 2008

After last night's round of updates applied from Microsoft my mssql_connect stopped working.

tsql -LH x.x.x.x still shows the server and port correctly

tsql -H x.x.x.x -U user connects fine

I get nothing in the apache log files or the freetds log

Here is the code segment that is failing (critical info changed)

error_reporting(E_ALL); ini_set('display_errors',1);
$con = mssql_connect('server', 'user', 'pass');
var_dump($con);
if (!$con) {
    if ( function_exists('error_get_last') ) {
        var_dump(error_get_last());
    }
    die('Could not connect to the server!!'.mssql_get_last_message());
}

And here is the result:

Warning: mssql_connect(): Unable to connect to server: server in /home/....../public_html/states/index.php on line 25
bool(false)
array(4) { ["type"]=> int(2)
["message"]=> string(55) "mssql_connect(): Unable to connect to server: server"
["file"]=> string(63) "/home/....../public_html/states/index.php"
["line"]=> int(25) } Could not connect to the server!!

Please help!

2

2 Answers

0
votes

I'm unable to post a comment to ask this, but here is my thoughts.

  1. Obviously it's not connecting to the server outside of the command line, so you'll want to double check its configuration (check the server port, specify the port, etc..)

  2. Is this running from a Win or Unix type OS?

0
votes

It is Linux. I found a work around for the moment. The problem appears to be on the Windows side where, although a tsql -LH command shows the IP and port, it is not actually answering queries on the port. You get connected to the server via TCP and that is it.

Because the SQL server is multi-homed, I added a secondary connection to the web app server that connects to it over the primary IP.

I'll chase down the IP binding and service issue later. Or maybe just convert it all to mariaDB or Postgres.