I had a quick look at your code, and I see the issue.
You’ve written the database hostname (as well as all other credentials), like this:
$db_host = "
sql208.infinityfree.com";
By writing it like this, you introduce an additional newline character before the actual hostname. And \nsql208.infinityfree.com
is not the same as sql208.infinityfree.com
, and the former will not work.
I would suggest putting the setting on a single line, like so:
$db_host = "sql208.infinityfree.com";
If you do insist on having it on multiple lines, then you should put the quote on the next line too, like:
$db_host =
"sql208.infinityfree.com";
This also goes for any whitespace or newlines after variable contents (like is the case with the database name).
And this also applies to using the variables elsewhere. You’re establishing the database connection like this:
$conn = mysqli_connect(
"$db_host", "$db_username", "$db_pass
","$db_name
");
By having all the quotes and newlines here, you’re adding additional whitespace characters at the end of the password and database name, which will break your connection again, even if you created the variables correct.
And you don’t even need to reformat your code for this. Just remove the quotes and this code will work. There are only downsides to adding the additional quotes. Just pass the variables into the code as variables.