PHP MySQL Error on InfinityFree: Access denied even with correct password

Website URL

https://mkmassagem.page.gd/

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:

  1. 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).

  2. Username: The username ifo_40357705 is correct.

  3. Database Name: The database ifo_40357705_mk_massotherapy is 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!

Sharing your hosting account password with an AI tool to write a message is not a great idea in the first place, but make sure to absolutely never share your password publicly! Remember that this is a public forum, anything you write here is visible to anyone, so do not share any sensitive data like passwords, API keys, or PII you’re not willing to share.

I removed both occurrences of your password from your post. Please be careful not to do it again.


As for the question yourself, the issue is very simple: our usernames start with if0_, not ifo_. That’s a zero, not a letter. That’s wrong in both the database username and the database name. I didn’t check whether your password is correct, but I suggest trying the correct username and database name first and see if that solves the issue.

8 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.