2

I have a mysql server installed on windows 2003 machine. When I try to connect to this server remotely with PHP, it gives "system error: 111" error, but when I try to connect using commmand prompt or using mysqlyog, it always connects.

works well this command

mysql -h 192.168.0.10 -u root

and here is the php code

<?
    session_start();
    $PHPSESSID = session_id();

        define("DB_SERVER", "192.168.0.10");
    define("STOCK_DB", "stock");
    define("MASTER_DB", "masterstock");
    define("DB_USERNAME", "root");
    define("DB_PASSWORD", "");
    define("DB_PREFIX", "mlc");

        function makeconnection()
        {
                $link = mysql_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD);
                if (!$link) 
                {
                        die('Error while connecting to MySQL : ' . mysql_error());
                }

                $db = mysql_select_db(MASTER_DB, $link);

                if (!$db)
                {
                        die ('Can\'t Open Database : ' . mysql_error());
                }
        }

?>      

*Edit: Please note, I am able to connect locally, able to connect remotely using command prompt *

Any help.

Gajendra Bang
  • 3,593
  • 1
  • 27
  • 32
  • Possible duplicate of http://stackoverflow.com/questions/1420839/cant-connect-to-mysql-server-error-111 – kongr45gpen Jul 05 '11 at 12:27
  • No, not a duplicate, becuase in my case I am able to connect using command prompt or mysqlyog. I am getting this error when I try to connect with PHP remotely. – Gajendra Bang Jul 05 '11 at 12:30

2 Answers2

2

I contacted the hosting, and they fixed it. Actually, port 3306 going outbound was not open

Gajendra Bang
  • 3,593
  • 1
  • 27
  • 32
1

Make sure your firewall is not blocking the port.

Rob
  • 2,618
  • 2
  • 22
  • 29
  • I am trying to go thru the simple things first :). the symptom looks very much like the remote communication is being blocked. Odds are the server firewall is blocking the communication port. – Rob Jul 05 '11 at 12:39
  • but what about the thing that I am able to connect using mysqlyog and command prompt :) – Gajendra Bang Jul 05 '11 at 13:45
  • Are you able to connect from a remote machine that way? – Rob Jul 05 '11 at 13:59
  • Ya, I am able to connect to it using command prompt and even mysqlyog – Gajendra Bang Jul 05 '11 at 18:01