views:

18

answers:

1

I have been trying to connect to my database using pdo on godaddy with no successs.

Initially i got the error:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Then i look around the web, found out that i need to change the part to socket. I looked for my socket found it and changed it using unix_socket=/tmp/mysql-1.sock. Now i get the error:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql-1.sock' (2)

I have also tried changing the host and hostname to the IP address of server hosting the database and still get the same error.

Please can someone help me. Im hosting on godaddy.

Thanks in advance.

EDIT #1

$dbh = new PDO('mysql: hostname=122.100.111.0;port=3306;unix_socket=/tmp/mysql-1.sock; dbname=orson', 'username', 'password');
    foreach($dbh->query('SELECT * from q_users') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";

}
A: 

After exchanging messages with the Godaddy Support Team i found out that they don't support PDO on their shared hosting plan.

Colour Blend
I'd say this anyway, but drop them like a rock. There is no reason at all whatsoever that they should not support PDO. (That being said, your error is due to MySQL looking for a socket file instead of trying to connect to a port...)
Charles
Thanks for the explanation.
Colour Blend
What host do you use please?
Colour Blend