You might try an fsockopen() to port 3306 on the dbserver and see if it 
works.  If not, you get a reasonably descriptive error.

I just tried a couple of known servers and bogus addresses with this 
code:

<?php
$ipaddr = "localhost";  # substitute the IP address here
$fp = fsockopen($ipaddr, 3306, $errno, $errstr, 5.0);
var_dump($fp, $errno, $errstr);
if ($fp)
        fclose($fp);
?>

A server listening on that port produces:

    resource(4) of type (stream)
    string(0) ""
    NULL

One that is not produces:

    Warning: fsockopen() [http://www.php.net/function.fsockopen]:
    unable to connect to 192.168.1.1:3306 in d:\TEST2.PHP on line 2 
    bool(false)
    int(10060)
    string(185) "A connection attempt failed because the connected
    party did not properly respond after a period of time, or
    established connection failed because connected host has failed to
    respond." 

I get the same response whether I try it from CLI or within Apache.  I 
did the test on Windows but the same would work and might tell you 
something useful if run from the server.

--
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to