|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49288 mssql_connect: Can't connect to database
Submitted: 2009-08-18 14:08 UTC Modified: 2009-08-18 14:48 UTC
From: claudio_reis at aeiou dot pt Assigned:
Status: Closed Package: MSSQL related
PHP Version: 5.2SVN-2009-08-18 (snap) OS: Windows Server 2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
47 + 11 = ?
Subscribe to this entry?

 [2009-08-18 14:08 UTC] claudio_reis at aeiou dot pt
The code used to create a connection to a MS SQL database works fine when running under a webserver (IIS 6.0) but fails when running from a command line. I used the same file in both scenarios to be 100% sure. 

Using the netcap2 tool i found that when running as a command line(or task) it tries to comunicate to the ms sql server using SMB protocol and tries to do a tree connect. The sql server responds with a STATUS_BAD_NETWORK_NAME. Result the connection cannot be done.

When running in the webserver context it queries the dns for the server ip then it stablish a connection  to the 4414 port(ms-sql-m).

Why this strange behaviour? Thanks for your help.

Other info that can be usefull

SQL Server Enterprise Edition
Microsoft Windows NT - 5.0(2195)

Windows Server:
MS Windows Server 2003 R2

mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off

Reproduce code:
/* connection string ommited for security reasons */
if ($con = mssql_connect("SERVER","USER","PASSWORD")){ print("YES");}
else{ print("NO")}

Expected result:

Actual result:
can't connect to server


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-18 14:48 UTC] claudio_reis at aeiou dot pt
I remove the "ntwdblib.dll" from the php directory and it starts to work in both browser and task context
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 23:01:28 2024 UTC