I am an amateur programmer and I have a problem printing a php echo inside a div.
I have a file that, when accessed (one time only) will start the installation of the database:
mysqli_report(MYSQLI_REPORT_STRICT);
try
{
$mysqli = new mysqli("localhost","root","");
$mysqli->query("CREATE DATABASE IF NOT EXISTS respostas;");
$ok = "Banco de dados criado com sucesso...";
}
catch (Exception $e)
{
$error = "Desculpe alguma coisa não deu certo. Detalhes: " . $e->message;
}
And display the result in <div id="progress">
$pageBody = <<< EOPAGE
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Home | Configuração </title>
<meta http-equiv="Content-Type" content="txt/html; charset=utf-8" />
</head>
<body>
<div class="body">
<div class="text">
<p><h1>Bem Vindo</h1></p>
<br/>
<br/>
<p class="texts"><i class="fa fa-cog"></i>Iniciaremos agora as configurações finais. Aguarde enquanto todos os arquivos são configurados.</p>
<div id="progress">
<p>Aguardando</p>
<p>$ok</p>
<p>$error</p>
</div>
</div>
</div>
</body>
</html>
EOPAGE;
echo $pageBody;
However, when I call $ok
the message is displayed normally, but when I call $erro
it does not display error message, even simulated a connection error with the server, and the code gives error.