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/>";
}