Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in C:\xampp\htdocs\blog\config.php on line 3
Fatal error: Uncaught Error: mysqli object is already closed in C:\xampp\htdocs\blog\config.php:4 Stack trace: #0 C:\xampp\htdocs\blog\config.php(4): mysqli->set_charset('utf8') #1 C:\xampp\htdocs\blog\index.php(3): require('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\blog\config.php on line 4
Artigo.php
<?php
require 'config.php';
require 'src/Artigo.php';
$obj_artigo = new Artigo($mysql);
$artigo = $obj_artigo->encontrarPorId($_GET['id']);
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Meu Blog</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<h1>
<?php echo $artigo['titulo']; ?>
</h1>
<p>
<?php echo $artigo['conteudo']; ?>
</p>
<div>
<a class="botao botao-block" href="index.php">Voltar</a>
</div>
</div>
</body>
</html>
config.php
<?php
$mysql = new mysqli('localhost', 'root', '', 'blog');
$mysql->set_charset('utf8');
if ($mysql == FALSE) {
echo "Erro na conexão";
}
index.php
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Meu Blog</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<h1>Meu Blog</h1>
<?php foreach ($artigos as $artigo) : ?>
<h2>
<a href="artigo.php?id=<?php echo $artigo['id']; ?>">
<?php echo $artigo['titulo']; ?>
</a>
</h2>
<p>
<?php echo $artigo['conteudo']; ?>
</p>
<?php endforeach; ?>
</div>
</body>
</html>
OQUE ESTÁ DANDO ERRADO?