php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43645 PHP 5.2.5 + php_mssql OR FreeTDS does not work
Submitted: 2007-12-20 18:16 UTC Modified: 2008-02-20 17:49 UTC
Votes:7
Avg. Score:5.0 ± 0.0
Reproduced:7 of 7 (100.0%)
Same Version:7 (100.0%)
Same OS:6 (85.7%)
From: earnest dot berry at gmail dot com Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 5.2.5 OS: Windows/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: earnest dot berry at gmail dot com
New email:
PHP Version: OS:

 

 [2007-12-20 18:16 UTC] earnest dot berry at gmail dot com
Description:
------------
I've tried using FreeTDS on Windows. With build 5.2.5, the php_mssql driver does not work. I haven't had a chance to investigate what changed in 5.2.5 to make this happen. 
I had an application running perfectly using PHP+MSSQL but upon upgrading to 5.2.5 all failed. When I down-graded, the application worked again.
Also, if anyone is wondering, yes, I am using the updated ntwlib, no the default one that comes with PHP. Also, if I use the microsoft SQL Driver ( http://www.microsoft.com/sql/technologies/php/default.mspx ) using 5.2.5, I can connect to SQL Server just fine, so this leads me to believe it's a problem with 5.2.5 in particular.
Also, I am not using the default port of 1433, but I have tried this connection using bot hthe default port of 1433 and the port I set to no avail. But the SQL Driver from MSFT will connect on either port, and when I downgrade it connects on either port fine.

Reproduce code:
---------------
$server = "localhost";
$port = "5356";
$username = 'webapp';
$password = '**********';
$db = 'drupal5';
$con = mssql_connect("$server,$port", $username, $password);  

if($con) {
  print "<h2>We have a connection!</h2>";
}
else {
  print "<h1>NO CONNECTION TO |$server,$port| $username, $password! ERROR!</h2>";
}



Expected result:
----------------
A screen that says: "We have a connection!"

Actual result:
--------------
A screen that says: "NO CONNECTION" with connection information.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-20 18:18 UTC] earnest dot berry at gmail dot com
I also forgot to add that this issue has been verified by another independent developer. He had the same issue when trying to move to 5.2.5.
 [2007-12-20 22:28 UTC] pcorbe81 at maine dot edu
I have the same setup and once I upgraded to 5.2.5, I received the same error. When I downgraded back to 5.2.3, it worked fine. I also used the same php.ini as I had in 5.2.3 and also tried modifying the new php-dist.ini with no avail. I am using the php_mssql.dll driver in conjuction with ntwlib.dll (same as the one described by above). I would agree that there seems to be something different in 5.2.5 that is causing this, although I can't tell what either.
 [2008-02-20 17:49 UTC] fmk@php.net
the native mssql_connect() function does not support the use of a port number as part of the first parameter, and if I recall correct that's not supported with FreeTDS either.

If you are using ntwdblib you should install and use the 'Network CLient Library' and configure an alias. The alias will have parameters like protocol, IP address and port number. The alias should be used for the first parameter of mssql_connect()

if you are using FreeTDS you need to configure freetds.conf. In there you can create sections like this

[host_name]
	host = localhost
	port = 1433
	tds version = 7.0
;	try domain login = yes
;	try server login = no
;	nt domain = MYDOMAIN

Use the name in the brackets as the first parameter to mssql_connect.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Sep 28 06:05:53 2022 UTC