I have a really strange problem. I want to load the MySQL connection attributes from an XML file, but I got this error when I try to process the connection:
php_network_getaddresses: getaddrinfo failed (Error number: 2002)
And why this is strange? Because if I just write down the mysql_connect() statement myself, and not from the xml file, it works.
The XML file looks like that:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<host>"localhost"</host>
<username>"root"</username>
<password>"password"</password>
<database>"account"</database>
</data>
The PHP part:
function connection() {
$file = 'access.xml';
if(file_exists($file)) {
$xml = simplexml_load_file($file);
$host = $xml->host;
$name = $xml->username;
$password = $xml->password;
$database = $xml->database;
$connect = mysql_connect($host,$name,$password);
//mysql_select_db($database) or die("Adatbázis csatlakozás sikertelen.");
} else {
print "XML betöltése sikertelen. - MySQL csatlakozás sikertelen."; // Error message in hungarian language
}
}
I thought about maybe the charset causes the problem, but no, because I already set the PHP's charset to UTF-8, my SQL server's charset is UTF-8, too, and as you can see, the XML file uses UTF-8. So, I really don't know what's the problem.
Thanks for the help,
Tomco