I am a student and in one of my video classes I realize that my code is broken by using the function fetch_all (MYSQLI_ASSOC) verify the syntax of my code again and again until I have done it practically from the beginning and not yet I can solve the problem.
<?php include_once 'includes/templates/header.php'; ?>
<section class="seccion contenedor">
<h2>Calendario de Eventos</h2>
<?php
try {
require_once('includes/funciones/bd_conexion.php');
$sql = 'SELECT* FROM 'eventos';';
$resultado = $conn->query($sql);
} catch (Exception $e) {
$error = $e->getMessage();
}
?>
<?php while($eventos = $resultado->fetch_all(MYSQLI_ASSOC) ) { ?>
<pre><?php var_dump($eventos); ?></pre>
<?php } ?>
</section>
That would be the code that should work, when I save the changes and reload the browser only loads the part of the "header.php" and the title "Calendar of Events" and the "footer.php" does not appear. It's like I'm not there. In fact
<?php include_once 'includes/templates/header.php'; ?>
<section class="seccion contenedor">
<h2>Calendario de Eventos</h2>
<?php
try {
require_once('includes/funciones/bd_conexion.php');
$sql = 'SELECT* FROM 'eventos';';
$resultado = $conn->query($sql);
} catch (Exception $e) {
$error = $e->getMessage();
}
?>
<?php while($eventos = $resultado->fetch_assoc() ) { ?>
<pre><?php var_dump($eventos); ?></pre>
<?php } ?>
</section>
If I change the function mentioned above by fetch_assoc () it works correctly without problems. The problem is that to continue with the video class I have to use fetch_all (MYSQLI_ASSOC). Otherwise, I do not get the results I should get.