tags:

views:

537

answers:

3

I'm hosting a website on Zymic (free host) that utilizes MySQL. I opened an account, and wrote the SIMPLEST function to connect to the DB. It looks like this:

<?php
    $conn = mysql_connect("uuuq.com","paulasplace_sudo","mypassword");
    if(!$con)
    {
        die("Could not connect: " . mysql_error());
    }
    else
    {
        echo("mysql connected successfully!");
    }
?>

but it throws this error:

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /www/uuuq.com/p/a/u/paulasplace/htdocs/index.php on line 9 Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 111

Any ideas what might be wrong?

A: 

I suspect the hostname is "localhost" and not uuuq.com.

artlung
i just tried that, and i get no error. Just "Could not connect: "
BBetances
+2  A: 

This may be just from when you copied the code into your post, but you store the results of mysql_connect() into $conn, but the if statement checks a different variably $con...

DeadHead
I cant believe i missed that. So stupid.
BBetances
A: 

Often times these free hosts have their MySQL servers at different addresses altogether as opposed to simply localhost or the site address itself.

If the host provides access to phpMyAdmin, open that then look at the top of the page and you should see something along the lines of

Server: s1.mysqlserver.com

That is the address you want.

Zurahn