SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: MS SQL Connect

  1. #1
    SitePoint Enthusiast Patrick Lucas's Avatar
    Join Date
    Dec 2001
    Location
    Ohio
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MS SQL Connect

    Hey,

    I've been having some trouble connecting to a MS SQL server through PHP. Since PHP doesn't have the MSSQL functions by default, I think I went through all of the proper steps to add them. However, I am still having trouble connecting.

    Here's my code:

    PHP Code:
    <?php
    $hostname 
    '10.89.192.23'
    $username "xxx"
    $password "xxx";  
    if(!
    mssql_connect($hostname,$username,$password)) {
     
    //echo "Error connecting to MS SQL Server";
    }
    else {
     echo 
    "Success!";
    }
    ?>
    Now here is what I get:

    PHP Code:
    [b][size=1]Warningmssql_connect() [[/size][/b][url=http://www.php.net/function.mssql-connect][size=1][color=#0000ff][b]function.mssql-connect[/b][/color][/size][/url][b][size=1]]: Unable to connect to server: 10.89.192.23 in D:\WEB\test\index.php on line 7[/size][/b] 

    Even if the username/password is wrong, it still shouldn't say "unable to connect to the server," right? I am positive that is the right address of the SQL Server and I know it uses the default port. Can anybody think of what I am doing wrong?

    Also, I am failry sure the SQL server is setup correctly. People are able to remotly connect to it (through that IP) using methods other than PHP.

    Thanks for your help!
    Patrick Lucas

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your server is a windows box you have to have the MS SQL client tools installed. If you're serving from a *nix box you may have to connect via ODBC.

  3. #3
    SitePoint Enthusiast Patrick Lucas's Avatar
    Join Date
    Dec 2001
    Location
    Ohio
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by broken
    If your server is a windows box you have to have the MS SQL client tools installed. If you're serving from a *nix box you may have to connect via ODBC.
    Hey, thanks for your response.

    It is a windows server. I copied that .dll file from the SQL server... Was that enough I wonder?

    Thanks!
    Patrick Lucas

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, let me know if that works. I've always just installed the client tools on the server.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •