Php_network_getaddresses: getaddrinfo failed

$db = mysqli_connect("http://MYHOST.domain", "USERNAME", "PASSWORD", "DATABASE");
// getting rid of DATABASE in the string doesn't help, same result //
if (!$db) {
    die("Connection failed: " . mysqli_connect_error());
}

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

Where did I go wrong?

Don’t use http:// for the domain.

In fact, if the MySQL server is located on the same server as the script that is accessing it, then you probably want to use localhost as the hostname to connect to:

$db = mysqli_connect("localhost", "USERNAME", "PASSWORD", "DATABASE");

or

$db = mysqli_connect("DOMAIN", "USERNAME", "PASSWORD", "DATABASE");

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.