By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

PHP with SQL Server

P: n/a
I am unable to connect to certain SQL servers from PHP on IIS.

I have two IIS 5 servers, both are Windows 2000 Server boxes with PHP
4.3.4 and MDAC 2.80.1022.3. I have three SQL Server machines - two
SQL2K SP3a machines and one SQL 7.0 SP4 machine. One of the SQL2K
servers is the same machine as one of the IIS 5 servers.

One of the IIS servers, Server1, can mssql_connect to all three SQL
servers. The other IIS server, Server2, can only mssql_connect to one
of the SQL2K servers. I get a "connect failed" error when attempting
to hit the other two SQL servers. The one it can connect to,
incidentally, is the SQL server that resides on the _other_ IIS
server.

I have tried copying the PHP application from Server1 to Server2. The
same PHP app that can connect to all three SQL Servers from Server1
can only connect to SQL on Server1 from Server2.

Here's a chart of the servers:

ServerName |OS |SQL Version |PHP Can connect to...
-------------|-----------|----------------|-------------------------
Server1 |Win2k Svr |SQL2K SP3a |Server1, Server3, Server4
Server2 |Win2k Svr |N/A |Server1
Server3 |NT 4.0 |SQL7 SP4 |N/A
Server4 |Win2k3Svr |SQL2K SP3a |N/A
Any insight would be greatly appreciated.
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Jack!

Someone called Google Mike has some threads running about SQL server
here as well. You should check them out.

On 25 Nov 2003 06:42:30 -0800, jo*******@county.allegheny.pa.us (Jack
Smith) wrote:
I am unable to connect to certain SQL servers from PHP on IIS.

I have two IIS 5 servers, both are Windows 2000 Server boxes with PHP
4.3.4 and MDAC 2.80.1022.3. I have three SQL Server machines - two
SQL2K SP3a machines and one SQL 7.0 SP4 machine. One of the SQL2K
servers is the same machine as one of the IIS 5 servers.

One of the IIS servers, Server1, can mssql_connect to all three SQL
servers. The other IIS server, Server2, can only mssql_connect to one
of the SQL2K servers. I get a "connect failed" error when attempting
to hit the other two SQL servers. The one it can connect to,
incidentally, is the SQL server that resides on the _other_ IIS
server.
I would first check DNS and WINS. Open a cmd-prompt on the server
where it fails and connect to the server with telnet.

Eg. if you use "30.30.30.30:1433" try telnet 30.30.30.30 1433

ut if you use a name, try this one.

Eg. telnet sqlserver5 1433

If it connects, then its not a network problem, otherwise it is.
I have tried copying the PHP application from Server1 to Server2. The
same PHP app that can connect to all three SQL Servers from Server1
can only connect to SQL on Server1 from Server2.

Here's a chart of the servers:

ServerName |OS |SQL Version |PHP Can connect to...
-------------|-----------|----------------|-------------------------
Server1 |Win2k Svr |SQL2K SP3a |Server1, Server3, Server4
Server2 |Win2k Svr |N/A |Server1
Server3 |NT 4.0 |SQL7 SP4 |N/A
Server4 |Win2k3Svr |SQL2K SP3a |N/A
Any insight would be greatly appreciated.


HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

P: n/a
Jack Smith wrote:

One of the IIS servers, Server1, can mssql_connect to all three SQL
servers. The other IIS server, Server2, can only mssql_connect to one
of the SQL2K servers. I get a "connect failed" error when attempting
to hit the other two SQL servers. The one it can connect to,
incidentally, is the SQL server that resides on the _other_ IIS
server.


One/some of your SQL servers may be blocking IP addresses or ranges.
The server OS may also be blocking ports. Ports may be blocked on a
host/network basis.

check your IP filters on all machines concerned.

Jul 17 '05 #3

P: n/a
Thanks for your replies!

I forgot to mention in my post that I know it's not a network issue
because the same webserver, Server2, has ASP apps running with Server3
as a back-end. There are no problems. It was only a connection issue
when hitting Server3 and Server4 from Server2 with PHP.

I have found the problem - it was under my nose in the PHP manual
posts all along. I read through these before but must have had my
blinders on. The problem was with the ntwdblib.dll. Server1 had an
old version 7.00.xx. Server2 had version 8.00.xx. I copied the dll
from Server2 to Server1 and all was good with the world.
http://www.php.net/manual/en/function.mssql-connect.php
[snip]
Besides my comment about the instances of SQLServer (see above), its
very important to have the latest version of NTWDBLIB.DLL. With Php
4.2.1 comes de NTWDBLIB version 7.00, with this version the conection
isnīt work! you have to install the version that comes with the client
of SQLServer 2000. Be careful, because installing the client sometimes
doesnīt replace the NTWDBLIB, then search for it in the SQLServer
Installer Disc an replace it in the system32 directory of
Windows(SQLSERver 2000 comes with Version 8.00 of NTWDBLIB.DLL).
[/snip]
Jul 17 '05 #4

P: n/a
Do you have SQL Server Authentication enabled on all the servers? I
don't think PHP's MSSQL module can do Windows Authetication (I could
be wrong, however).

Try setting the SQL client's connection preference to TCP/IP (over
named pipe) as well.

jo*******@county.allegheny.pa.us (Jack Smith) wrote in message news:<b4**************************@posting.google. com>...
I am unable to connect to certain SQL servers from PHP on IIS.

I have two IIS 5 servers, both are Windows 2000 Server boxes with PHP
4.3.4 and MDAC 2.80.1022.3. I have three SQL Server machines - two
SQL2K SP3a machines and one SQL 7.0 SP4 machine. One of the SQL2K
servers is the same machine as one of the IIS 5 servers.

One of the IIS servers, Server1, can mssql_connect to all three SQL
servers. The other IIS server, Server2, can only mssql_connect to one
of the SQL2K servers. I get a "connect failed" error when attempting
to hit the other two SQL servers. The one it can connect to,
incidentally, is the SQL server that resides on the _other_ IIS
server.

I have tried copying the PHP application from Server1 to Server2. The
same PHP app that can connect to all three SQL Servers from Server1
can only connect to SQL on Server1 from Server2.

Here's a chart of the servers:

ServerName |OS |SQL Version |PHP Can connect to...
-------------|-----------|----------------|-------------------------
Server1 |Win2k Svr |SQL2K SP3a |Server1, Server3, Server4
Server2 |Win2k Svr |N/A |Server1
Server3 |NT 4.0 |SQL7 SP4 |N/A
Server4 |Win2k3Svr |SQL2K SP3a |N/A
Any insight would be greatly appreciated.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.