#40034 [Com]: mssql_connect(): Unable to connect to server
| From: | jmckinzie at novonics dot com | Date: | Sat, 30 Jun 2007 18:34:46 +0000 |
| Subject: | #40034 [Com]: mssql_connect(): Unable to connect to server | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114490@lists.php.net to get a copy of this message | ||
ID: 40034
Comment by: jmckinzie at novonics dot com
Reported By: chris dot clos at lmcu dot org
Status: Assigned
Bug Type: MSSQL related
Operating System: Windows Server 2003
PHP Version: 5.2.0
Assigned To: fmk
New Comment:
I may be having some similar behavior related to this bug. I'm having
issues with database connections dropping on a Win 2K3 box, running
Apache 1.3.37, PHP 5.1.6 and MS SQL 2005 Express. I am able to connect
most of the time using mssql_connect. However, on a consistent basis,
probably 15-45 minutes, my mssql_connect calls begin to fail with the
same message as above:
PHP Warning: mssql_connect(): Unable to connect to server: x.x.x.x
Restarting Apache fixes the problem and I am able to connect for a
short time. I'm using ntwdblib.dll, version 2000.80.194.0, and have not
upgraded to 2000.80.2039.0.
Previous Comments:
------------------------------------------------------------------------
[2007-01-23 05:36:47] ivanvart at gmail dot com
We have the same problem... we solved (but we dont know if is the best
option) changing the ntwdblib.dll (ver. 2000.80.2039.0) in the php
directory.
------------------------------------------------------------------------
[2007-01-22 21:18:17] tschoenbachler at eoncc dot com
I too has seen this problem on one of my customers machines and FYI,
restarting IIS temporarily fixes the problem. As a work around can I do
a regsvr32 on the new ntwdblib.dll and if so where can I get it...?
------------------------------------------------------------------------
[2007-01-12 16:30:37] fmk@php.net
But you are packing the dll's :-)
As far as I know different versions of ntwdblib.dll will default to
either tcpip or netbios for the default protocol. There might also be a
registry setting for this (I'll look for that tonight when I get home).
Just copying the dll to the system does not give you access to the
client configuration tools that allow you to change the defaults or
create server aliases that should be used as the host parameter for
mssql_connect().
If the newer version of ntwdblib.dll solves the problem I'd say we
should bundle it.
------------------------------------------------------------------------
[2007-01-12 14:11:43] edink@php.net
Sorry, I'm not the MSSQL intiated :)
Frank, could you take a look please?
------------------------------------------------------------------------
[2007-01-05 15:23:46] chris dot clos at lmcu dot org
Description:
------------
I have PHP 5.1.4 and upgraded to php 5.2.0. Copied my php.ini file
over. I use IIS in Server 2003 (Standard) SP1, connecting to SQL Server
2005 (Standard).
I can no longer do mssql_connects, instead I get an error.
Once I did this I get an error:
PHP Warning: mssql_connect(): Unable to connect to server: x.x.x.x in
C:\db-test.php on line 3
This is the same thing that happens when using it via IIS (using
php5isapi) or the php command line. This does work on a Windows XP SP2
machine just fine. I can reproduce this other Windows Server 2003
machines.
I read from bug Id 39313, and I have tried loading the client tools,
however I do not see anywhere that there is a NETBIOS or a TCP/IP type
setting in SQL Server Management Studio.
After looking long and deep, I found that its the version of
ntwdblib.dll that is provided with php package. I found one that is
version "2000.80.194.0" that fixes it, but the one included is
"2000.2.8.0"
Same problem appears to happen with 5.1.4 and this version of dll, I
think this file needs to be updated in the distribution.
Reproduce code:
---------------
<?php
$dbh = mssql_connect('x.x.x.x','user','password');
if($dbh) {
echo "true\r\n";
} else {
echo "fubar\r\n";
}
?>
Expected result:
----------------
I should get "true" printed out.
Actual result:
--------------
Using 5.2.0:
Warning: mssql_connect(): Unable to connect to server: x.x.x.x in
C:\db-test.php on line 3
fubar
Using 5.1.4:
true
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40034&edit=1