Connection failed: Access denied for user 'epiz_24968765'@'192.168.%

So when i try to connect it gives me this error.

here is the code. tell me whats wrong!

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "<br> id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"] . "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();
?>

I checked your code and that contains the default connection values, which will not work. You’ll have to use the database host and the database name from the “MySQL Databases” section of the Control Panel, along with the correct username and password you can find by logging into your Client Area, clicking on your hosting account, scrolling down to “Account Details” and clicking on “Show/Hide” to show the password.

2 Likes

@Ergastolator1 Probably they’ve edited the code before posting here!

https://infinityfree.net/support/common-mysql-errors/

Edit: it’s too similar to w3schools tutorial one…

3 Likes

its from the w3school site. basically i dont know anything about sql and i am trying to connect it to my page anyways i figured out that i didnt enter the db name correctly

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