How to connect PHP with MySQL

Why not? What do you see?

Please try to get the actual error message from the connection. That could look something like this:

$conn = new mysqli($servername, $username, $password,$dbname);
if ($conn->connection_error) {
    die("Database connection error: ".$mysqli->connect_error)
}

Once you have the actual connection error, please check it against the error messages in this article to learn what might be causing it:

3 Likes