1
I hosted a website on 007gb.with and I’m trying to access my remote database but I get the message
"Mensagem do erro: SQLSTATE[HY000] [2002] Connection refused
Code: 2002
Fatal error: Call to a member function prepare() on string in /srv/disk13/2292110/www/pirataswe0.medianewsonline.com/test.php on line 14"
What could it be? i created a script in php for ease:
<?php
function connectdb() {
try {
$return = new PDO("mysql:host=179.213.XX.XX;port=3306,dbname=pwdb;charset=utf8", 'root', '***********',[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
} catch (PDOException $exc) {
echo $return = 'Mensagem do erro: ' . $exc->getMessage().
'<br>Code: ' . $exc->getCode();
}
return $return;
}
$db = connectdb();
$select = $db->prepare("SELECT title FROM posts");
$select->execute();
echo $select->rowCount().'</br>';
while ($data = $select->fetch(PDO::FETCH_ASSOC)) {
echo $data['title'].'</br>';
}
The port is the same default, and it is open in the gateway that points to the local ip and port.