PHP with SQL Server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack Smith

    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.
  • Jochen Daum

    #2
    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@count y.allegheny.pa. us (Jack
    Smith) wrote:
    [color=blue]
    >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.[/color]

    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:14 33" 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.
    [color=blue]
    >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.[/color]

    HTH, Jochen


    --
    Jochen Daum - CANS Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

    Comment

    • Terence

      #3
      Re: PHP with SQL Server

      Jack Smith wrote:

      [color=blue]
      > 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.[/color]

      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.



      Comment

      • Jack Smith

        #4
        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.


        PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

        [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(SQLSERv er 2000 comes with Version 8.00 of NTWDBLIB.DLL).
        [/snip]

        Comment

        • Chung Leong

          #5
          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@count y.allegheny.pa. us (Jack Smith) wrote in message news:<b4011edc. 0311250642.190f 0a8e@posting.go ogle.com>...[color=blue]
          > 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.[/color]

          Comment

          Working...