Hi!

I am using PHP 4.3.6 under Windows 2000.

I have been always connected to and worked with my local mySQL databases without problems.

Now what I need is to connect to a remote MS-SQL host within a VPN:

$remote_server="99.999.999.99";
$user="xxxxx";
$pass="9999";
$conn = mssql_connect($remote_server,$user,$pass);
IF($conn > 0) 
      echo "OK!<BR>";   
else echo "Error!<BR>";

The error message I get is:

Warning: mssql_pconnect(): Unable to connect to server: 99.999.999.99 in C:\apache.....

I have tried with pmssql_connect and $remote_server="99.999.999.99,1433" too.

I ping the IP address and I get a normal response.

Any ideas ?
Please, I would need help ASAP!

Thank you in advance

    Are you using DreamweaverMX ? If it is, keep reading.

    You may want to try this and then do an F12:
    //unsure if this will work with that type of address//

    $remote_server="99.999.999.99";
    $user="xxxxx";
    $pass="9999";
    $conn = mssql_connect($remote_server,$user,$pass); or die(mysql_error());

    $Recordset1 = mysql_query("SHOW variables", $remote_server);

    echo "<table border=1 width=100%>";
    while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) {
    echo "<tr><td>".$row_Recordset1['Variable_name']."</td><td>".$row_Recordset1['Value']."</td></tr>";
    }
    echo "</table>";
    ?>

      Thank you for your reply. I do not use DreamweaverMX.

      I want to make clear that I have no problems with my local mySQL.
      My problem is that I cannot connect to an MSSQL remote server.

      Thanks!

      Please help!

        So, you have set the Permission on MS Sql to allow you to connect remotely correct?

        IN MySql, you have to explicitly state where your connections are coming from, like localhost, '%' (anyhost), 10.10.10.10 or a specific host witht the Username and password set appropriately.

          Have you allowed port 1433 through any firewalls?

            I tell you that I have just installed the Query Analyzer from the MS SQL Server 2000 CD and I got connected successfully to the remote MS SQL DB using the user_id and psw the remote owner of the DB provided me... but still cannot connect via PHP with the mssql_connect funtion :bemused:

            So... all security issue should be discarded.

            Does anybody have experience connecting to remote MS SQL DBs ??? it should be easy...

            Please help!

              5 days later

              Hello!

              I could resolve this issue by copying and overwriting the file ntwdblib.dll from the SQL Tools installation to my PHP installation.

              Now, I can get connected to the remote MS SQL DB.

              Thank you all!

                Hello... I am noticing that you are using mysql functions in the code above. Try changing all instances of mysql with mssql. This helped me to connect. Worth a try anyway...

                  Write a Reply...