php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: claudio_reis at aeiou dot pt
New email:
PHP Version: OS:

 

 [2009-08-18 14:08 UTC] claudio_reis at aeiou dot pt
Description:
------------
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
PHP VERSION:
PHP-5.2.9-2

MS SQL SERVER:
SQL Server Enterprise Edition
8.00.2184(SP4)
Microsoft Windows NT - 5.0(2195)

Windows Server:
MS Windows Server 2003 R2
SP2

php.ini:
[MSSQL]
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:
----------------
YES

Actual result:
--------------
can't connect to server

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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: Fri Apr 19 16:01:27 2024 UTC