|  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
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
 [2007-12-20 18:16 UTC] earnest dot berry at gmail dot com
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 ( ) 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.


Add a Patch

Pull Requests

Add a Pull Request


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]
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 = 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-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 01:01:28 2024 UTC