I try to connect to a distant host like this:
class Singleton {
public static $connection;
public static function getConnection(){
if(self::$connection==null){
$dsn = 'mysql:dbname=gtrscrpt_ubot;';
$user = 'MyUser';
$password = 'MyPassword';
try {
self::$connection = new PDO('mysql:host=gator188.hostgator.com;port=2983;dbname=gtrscpt_ubot;',$user,$password );
self::$connection->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
}
return self::$connection;
}
}
Singleton::getConnection();
I get this:
Connection failed: SQLSTATE[HY000] [2006] MySQL server has gone away
The problem is that I dont know if my code is wrong or cant I really connect to the server (I know however that I should connect)
UPDATE: Connection failed: SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file**