connecting to SQL Server using PHP

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

    connecting to SQL Server using PHP

    Hello,

    well, I am still trying to connect to SQL Server 2000 (MSDE) form PHP

    I did the following:
    1. enabled php_mssql.dll extension in php.ini (phpinfo() shows it)
    2. every dll is in proper place (System32 or php folder and few more
    folders just to be sure) including
    ntwdblib.dll

    I am running Apache, PHP 4.3.9 and MSDE on the same machine with Win2k

    SQL server config.:
    1. Two instances: default SERVER and SERVER\Portal
    2. Both instances are using SQL auth mode, and user that I try to log
    in has db admin rights

    can't connect to any of the instances :(

    I tried the following:
    1. specyfing the port in mssql_connect ('SERVER\Portal ,1433') DIDN'T
    WORK
    2. different notations 'SERVER\Portal' or 'SERVER\\Portal ' DIDN'T WORK
    3. different naming like: SERVER, localhost, 127.0.0.1 DIDN'T WORK

    The ASP pages that are using the same sql server work fine :| so there
    is a connection to the server for
    ASP :]

    So my question is what I did wrong?

    and another question is: How to connect to a named instance of a sql
    server if it isn't running on the
    same machine with web server, what would be the connection string in
    mssql_connect?? ????

    Thanks for any advice

    STEFAN

  • Allan

    #2
    Re: connecting to SQL Server using PHP

    Could you post any reply or errors from the PHP, so we can understand
    more about the situation

    Comment

    • stefanPL

      #3
      Re: connecting to SQL Server using PHP

      sure thing, here it is:

      Warning: mssql_connect() : Unable to connect to server: SERVER\Portal
      ....... on line 5

      on line 5 there is:
      $db_connect = mssql_connect(' SERVER\Portal', 'sa', 'my_passwd');

      Comment

      • box4dadoc@gmail.com

        #4
        Re: connecting to SQL Server using PHP

        maybe mssql_connect(' 127.0.0.1:1443' ,'sa','my_passw d') would work for
        you, replace 127.0.0.1 with you server network name or IP

        Comment

        • stefanPL

          #5
          Re: connecting to SQL Server using PHP

          didn't work :(
          moreover: I switched off my firewall and I still can't connect

          Comment

          • zurg

            #6
            Re: connecting to SQL Server using PHP

            I have bumped to this also, only thing that worked for
            me was to use odbc calls.

            The problem seems to be related to instances, if you don't have them
            and use default server then mssql functions work with sql server 2000.

            If there is a renamed instance (even if only one is running)
            I could not connect. The server does not listen on the default port
            but on something else.

            Comment

            • stefanPL

              #7
              Re: connecting to SQL Server using PHP

              OK I solved my problem

              Here is the routine:

              I needed Server Network Utility tool in order to enable TCP/IP for the
              instance that I want connect to. After I enabled it, the php connection
              works fine.

              Thanks for each answer

              STEFAN

              Comment

              • Chung Leong

                #8
                Re: connecting to SQL Server using PHP

                "stefanPL" <stefanet@poczt a.onet.pl> wrote in message
                news:1106907287 .691066.13150@c 13g2000cwb.goog legroups.com...[color=blue]
                > Hello,
                >
                > well, I am still trying to connect to SQL Server 2000 (MSDE) form PHP
                >
                > I did the following:
                > 1. enabled php_mssql.dll extension in php.ini (phpinfo() shows it)
                > 2. every dll is in proper place (System32 or php folder and few more
                > folders just to be sure) including
                > ntwdblib.dll
                >
                > I am running Apache, PHP 4.3.9 and MSDE on the same machine with Win2k
                >
                > SQL server config.:
                > 1. Two instances: default SERVER and SERVER\Portal
                > 2. Both instances are using SQL auth mode, and user that I try to log
                > in has db admin rights
                >
                > can't connect to any of the instances :(
                >
                > I tried the following:
                > 1. specyfing the port in mssql_connect ('SERVER\Portal ,1433') DIDN'T
                > WORK
                > 2. different notations 'SERVER\Portal' or 'SERVER\\Portal ' DIDN'T WORK
                > 3. different naming like: SERVER, localhost, 127.0.0.1 DIDN'T WORK
                >
                > The ASP pages that are using the same sql server work fine :| so there
                > is a connection to the server for
                > ASP :]
                >
                > So my question is what I did wrong?
                >
                > and another question is: How to connect to a named instance of a sql
                > server if it isn't running on the
                > same machine with web server, what would be the connection string in
                > mssql_connect?? ????
                >
                > Thanks for any advice
                >
                > STEFAN[/color]

                A wild guess: maybe the MSSQL client library in PHP doesn't support
                connecting a named instance? The library is for SQL Server 7, if I remember
                correctly.


                Comment

                Working...