PHP error connecting to MySQL database

0

Although I have not changed the settings of my MySQL database that has worked well for months, the connection has stopped working.

This is the PHP command I use to make the connection:

$this->link = @mysqli_connect($this->host,$this->user,$this->pass) or die("Sem conexão ". mysqli_connect_error());

Mysqli_connect_error returns this error message:

php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found.

These are the UOL Host connection settings:

public $host = "djbteste.mysql.uhserver.com";
public $user = "********";
public $pass = "********";
public $db = "djbteste";

But it is an intermittent error, it happens a few times throughout the day and only for a few minutes. I got in touch with the UOL Host support (which sucks!), And they said that everything is fine with the database ...

    
asked by anonymous 26.05.2018 / 13:52

1 answer

0

Try to use server IP in your $host variable.

public $host = "127.0.0.1.00"; // IP do servidor
public $user = "********";
public $pass = "********";
public $db = "djbteste";

Another thing, enter the bank name too, like this:

$this->link = @mysqli_connect($this->host,$this->user,$this->pass, $this->db);

or so:

$this->link = @mysqli_connect($this->host,$this->user,$this->pass);
mysqli_select_db($this->link,$this->db);
    
26.05.2018 / 19:56