I am having trouble connecting to my SQL database pointing to the domain. My connect.php
returns the following warning:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/1042): Can't get hostname for your address
connect.php
<?php
$server = "agenciaeficacia.com.br";
$user = "my-user";
$pass = "my-password";
$db = "my-db";
// CRIA CONEXÃO
$conexao = new mysqli($server, $user, $pass, $db);
// CHECA CONEXÃO
if ($conexao->connect_error) {
echo "Falha ao conectar com o banco de dados.";
}
date_default_timezone_set('America/Sao_Paulo');
?>
The weird thing is that the connection works on localhost
, but not when I upload it to the server (unless I use localhost
instead of my domain).
I have already tried the skip-name-resolve
solution, but it didn't work.
Is there another way to solve this problem?