Hi everyone,
I’m trying to connect my simple PHP website to my MySQL database on InfinityFree using the following db.php
code:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$host = 'sql100.infinityfree.com';
$user = 'if0_38872548';
$pass = 'xxxxxxx';
$db = 'if0_38872548_test';
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo "<strong>Fout:</strong> " . $conn->connect_error;
} else {
echo "✅ Connected";
}
?>
But I keep getting this error:
“Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo for sql100.infinityfree.com failed: Name or service not known in /home/stanson/public_html/db.php on line 11”
What I’ve tried so far:
- Double-checked my credentials
- Created a new database
- Verified phpMyAdmin works and the DB is active
- Enabled error reporting in PHP