When attempting to connect to my MySQL server with mysql_connect, it fails with the following message:

Warning: MySQL Connection Failed: Can't connect to MySQL server on 'montgoss-3' (110) in db.php on line 7
Could not connect: Can't connect to MySQL server on 'montgoss-3' (110)

I can login remotely to this machine with the same username/password using the mysql client. It just doesn't work through PHP. Any idea what's wrong?

    can you show us the script?

      $link = mysql_connect("montgoss-3", "uname", "pw");

      if (!$link) {
      die('Could not connect: ' . mysql_error());
      }
      mysql_select_db("bushtarion",$link);

      $result = mysql_query("SELECT * FROM users",$link);
      printf("%s of %s[%s]<br>\n", mysql_result($result,0,"id"), mysql_result($result,0,"name"), mysql_result($result,0,"company"));

        Hi,

        the error code 110 means "connection timed out". Is the MySQL server running on another port than 3306 ? Additionally, try to use the ip address instead of the host name. Which MySQL server version do you want to connect to and which MySQL client lib version does PHP use ?

        Thomas

          No, the MySQL server is running on port 3306. I tried the IP address with the same error(before I posted).

          The MySQL server is version 4.0. According to phpinfo(), the PHP server uses "Client API version 3.23.58". Does that mean it's incompatible? Should it have version 4.0 or higher?

            if it works when you log on to the machine, then probably your username is localhost based:

            instead of
            $link = mysql_connect("montgoss-3", "uname", "pw");

            Try
            $link = mysql_connect("localhost", "uname", "pw");

            OR if that fails
            $link = mysql_connect("127.0.0.1", "uname", "pw");

              Write a Reply...