我有一个
website
由DreamHost托管。子域“fakestore”有一个数据库,因此有一个访问该数据库的脚本。然而,我无法使该数据库正常工作。我试过换衣服
$servername
到
127.0.0.1
,和至
aashishbharadwaj.com
。如果使用localhost,则会出现错误
It no work!SQLSTATE[HY000] [2002] No such file or directory
.如果我用另外两个
It no work!SQLSTATE[HY000] [2002] Connection refused
。
<?php
$servername = 'localhost'; //I've tried numerous things here, with different errors
//For my server
$username = "username"; //Not actual username
$password = "password"; //Not actual password
$dbname = 'database_name'; //Not actual database name
try {
$db = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
} catch (PDOException $e) {
$error_message = $e->getMessage();
echo "It no work!";
echo $error_message;
exit();
}
?>