PHP with SQL Server

This is a discussion on PHP with SQL Server within the PHP Language forums, part of the PHP Programming Forums category; I am unable to connect to certain SQL servers from PHP on IIS. I have two IIS 5 servers, both ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-25-2003
Jack Smith
 
Posts: n/a
Default PHP with SQL Server

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.
Reply With Quote
  #2 (permalink)  
Old 11-25-2003
Jochen Daum
 
Posts: n/a
Default Re: PHP with SQL Server

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, johnsmith@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/
Reply With Quote
  #3 (permalink)  
Old 11-26-2003
Terence
 
Posts: n/a
Default Re: PHP with SQL Server

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.



Reply With Quote
  #4 (permalink)  
Old 11-26-2003
Jack Smith
 
Posts: n/a
Default Re: PHP with SQL Server

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]
Reply With Quote
  #5 (permalink)  
Old 11-27-2003
Chung Leong
 
Posts: n/a
Default Re: PHP with SQL Server

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.

johnsmith@county.allegheny.pa.us (Jack Smith) wrote in message news:<b4011edc.0311250642.190f0a8e@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.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0