Connection failed: php_network_getaddresses: getaddrinfo failed: Name or service not known
Other Information
Hi There,
I am trying to connect to my mysql database from my php script called test.php. I have tried both mysql hostname: sql110.epizy. com and sql110.infinityfree. com. The password is the one created when click the show/hide button.
I add spaces to the two hostname urls to bypass the topic posting system
This is really unnecessary.
Admin does not provide premium hosting on his own (what you know about premium hosting is ifastnet ruled by someone else)
The forum exists so others can help the people who have issues + different users can look up the answers via the search feature here.
Can you try formatting your code to be more readable?
From the code you sent, it appears that you’ve put an extra space before closing the quotation marks around your database name, so that could be a reason why you are getting an error.
I am curious, why do you hardcode it in the connection instead of creating a variable like you have done with the other values?
I took a look at the actual code that’s on your site, and there is a small but critical difference between what’s in the file and what you’ve shared here.
Because the current content of line two is this:
$servername = "sql110.infinityfree.com ";
At the end of the servername string is a trailing space. That may seem irrelevant, but when it comes to configuration, the value must be exactly the right one, and adding a space makes it a different value.
If you remove the space, it will fix this error.
Changing just this won’t also fix your database connection. The password in the config file is no longer correct because you already change the password of your account. And the password string also contains extra spaces, which will also break it.
Finally, you may also need to add the database name to the connect function. And as with the hostname and password: please make sure that no extra spaces are included.
Well the problem is solved but the issue was that somehow the ftp server wasnt saving my changes without telling me.
I already tried removing the extra spaces and including the dnmane I also tried the other sql hostname(the one in cpanel is different then the one in main mysql account tab). None of these worked because of the above mentioned bug that the ftp server wasn’t actually saving my changes to the file.