[freetds] Re: connecting to remote MS Sql 2k server from linux PHP

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Tue Nov 2 08:20:28 EST 2004


> 
> Ok, I'm kind of at the end of my patience here... Is there 
> anyone out there
> that would set this up for either free or for a fee?
> 

Try this script

<?php
error_reporting(E_ALL);

$service_port = 1433;
$address = gethostbyname('66.208.184.170');

echo "<h2>TCP/IP Connection</h2>\n";

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
   echo "socket_create() failed: reason: " . socket_strerror($socket) .
"<br>";
   exit(1);
} else {
   echo "OK.<br>";
}

echo "Trying to connect to '$address' on port '$service_port'...";
$result = socket_connect($socket, $address, $service_port);
if ($result < 0) {
   echo "socket_connect() failed. reason: ($result) " .
socket_strerror($result) . "<br>";
   exit(1);
} else {
   echo "OK.<br>";
}

echo "Closing socket...";
socket_close($socket);
echo "OK.<br>";
?> 

It should return a page with

TCP/IP Connection
OK.
OK.
OK.

An error means connection problems

freddy77



More information about the FreeTDS mailing list