Website URL
Error Message
Fatal error: Uncaught mysqli_sql_exception: Access denied for user ‘ifo_40357705’@‘192.168.0.41’ (using password: YES) in /home/vol15_7/infinityfree.com/if0_40357705/htdocs/conexao.php:9 Stack trace: #0 /home/vol15_7/infinityfree.com/if0_40357705/htdocs/conexao.php(9): mysqli->__construct(‘sql102.infinity…’, ‘ifo_40357705’, Object(SensitiveParameterValue), ‘ifo_40357705_mk…’) #1 /home/vol15_7/infinityfree.com/if0_40357705/htdocs/enviar_contato.php(14): require_once(‘/home/vol15_7/i…’) #2 {main} thrown in /home/vol15_7/infinityfree.com/if0_40357705/htdocs/conexao.php on line 9
Other Information
Hi everyone,
I’m having a problem with my PHP contact form on InfinityFree. I’m trying to connect to my MySQL database to save form data, but I keep getting a fatal error, even though I’m sure my credentials are correct.
When the script enviar_contato.php tries to run require_once 'conexao.php', the site crashes and shows this error.
<?php
// Database Settings for InfinityFree
$host = "sql102.infinityfree.com";
$usuario = "ifo_40357705";
$senha = "REMOVED"; // This is the password I am using
$banco = "ifo_40357705_mk_massotherapy";
// 1. Attempt connection
// THIS IS LINE 9, WHERE THE ERROR HAPPENS
$conexao = new mysqli($host, $usuario, $senha, $banco);
// 2. Check for connection error
if ($conexao->connect_error) {
die("Connection failed: " . $conexao->connect_error);
}
// 3. Set charset
$conexao->set_charset("utf8mb4");
?>
Why I Am Confused:
I am 100% sure that the password REMOVED is correct. It is the exact same password shown in my InfinityFree “Account Details” panel (the one I also use for FTP, which works perfectly).
What I have already checked:
-
Host: I am using
sql102.infinityfree.com, which is listed as the “MySQL Host Name” in the cPanel, not the “Website IP” (185.27.134.139). -
Username: The username
ifo_40357705is correct. -
Database Name: The database
ifo_40357705_mk_massotherapyis also correct.
Why am I getting Access denied? Is it possible that the MySQL password is different from my main Account/FTP password, even if the username is the same?
Any help would be appreciated. Thank you!