( ! ) Fatal error: Uncaught TypeError: Cannot access offset of type string on string in C:\wamp64\www\Recette5\home.php on line 32
( ! ) TypeError: Cannot access offset of type string on string in C:\wamp64\www\Recette5\home.php on line 32
---code---
<?php
session_start();
require_once(__DIR__ . '/config/mysql.php');
$stmt = $pdo->prepare('SELECT title, recipe, author FROM recipes');
$stmt->execute();
$recipe = $stmt->fetch();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php if(isset($_SESSION['LOGGED_USER'])) : ?>
<p>Bienvenu(e) <?php echo $_SESSION['LOGGED_USER']; ?> !</p>
<?php endif; ?>
<h1>RECETTE</h1>
<?php foreach($recipe as $r): ?>
<p><?php echo $r['title']; ?></p>
<p><?php echo $r['recipe']; ?></p>
<p><?php echo $r['author']; ?></p>
<?php endforeach; ?>
<button type='button' ><a href="create_recipes.php">Créer une recette</a></button><br>
<a href="logout.php">Déconnexion</a>
</body>
</html>
Je vous remercie par avance pour votre aide