Link to home
Start Free TrialLog in
Avatar of ksuchy
ksuchyFlag for United States of America

asked on

I am unable to connect using the new CPT beta sqlsrv_ts.dll php extension created by Microsoft and not an officially supported extension (at php.net).

PROBLEM STATEMENT:  I am unable to connect using the new CPT beta sqlsrv extension created by Microsoft and not an officially supported extension (at php.net).

I verified with phpinfo that sqlsrv extension (using sqlsrv_ts.dll) is loading fine, but the below syntax does NOT work
===========//BEGIN QUOTE//==========
<?php
/* Specify the server and connection string attributes. */
$serverName = "(FQDN or just HOST)";

/* Get UID and PWD from application-specific files.  */
$uid = ("myUserID");
$pwd = ("myPw");
$connectionInfo = array( "UID"=>$uid,
                         "PWD"=>$pwd,
                         "Database"=>"testdb");

/* Connect using SQL Server Authentication. */
if( !( $conn = sqlsrv_connect( $serverName, $connectionInfo)))
{
     echo "Unable to connect.</br>";
     die( print_r( sqlsrv_errors(), true));
}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
===========//END QUOTE//==========

I'm don't think its makes a diff to this problem, but I'm using sqlsrv_ts.dll, rather than sqlsrv.dll because of the php binaries I installed.

I have version 8.00.194 of ntwdblib.dll in sys32 dir and in c:\php\ and IUSR has full control over it.
At this point, I'm not worried about security, so much as getting this thing to work.  I can tighten down later if need be.  So I also gave IUSR read/write over the sql server subkey in the registry odbc hive

IMPORTANT: I installed SQL client connectivity tools, and I got the more traditional (and php team supported 'official') extension called mssql_connect to work, and select/print from tables works ok now with EITHER the odbc_connect or mssql_connect in php.  But I'm still not able to get sqlsrv_connect to work.

There are also a couple ASP applications that connect to this same SQL 2000 db instance.

Here is the error I get:
===========//BEGIN QUOTE//==========
Unable to connect.
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53]. [message] => [Microsoft][SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Native Client]Login timeout expired [message] => [Microsoft][SQL Native Client]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. [message] => [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. ) )
===========//END QUOTE//==========
Note that telnet to 1433 from the IIS box connects fine.
ASKER CERTIFIED SOLUTION
Avatar of nmcdermaid
nmcdermaid

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ksuchy

ASKER

Hi MMCderMaid,

Thank you for tackling this one, a pretty tough one.  I agree that the problem certainly seems to indicate an issue with named pipes.   From my original question (just after my second script quote) "Note that telnet to 1433 from the IIS box connects fine."  Also, I should have been more clear, that these are in fact on separate boxes (otherwise, it would be oh-so-eazy).

It's been a while since I even looked at this problem (I have lots going on), but I'll try to find out what the others are using --- at this point, I don't even remember how to verify that, but I do recall that in the network tool thingy on SQL, I have TCP/IP listed first, ABOVE named pipes, which I think might have an order effect on attempts to connect?

Regards,
~k

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ksuchy

ASKER

I have verified positively that there the windows firewall.cpl is not enabled, and that no 3rd party firewall is installed on the IIS box, or the SQL box.  

Both boxes are on the same subnet, on the same LAN, using the same DNS servers (all my boxes, including the DCs for the AD which are running DNS).

What's next?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial