Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 in C:\MAMP\htdocs\forumf\allProfils.php:10 Stack trace: #0 C:\MAMP\htdocs\forumf\allProfils.php(10): PDO->query('SELECT * FROM u...') #1 {main} thrown in C:\MAMP\htdocs\forumf\allProfils.php on line 10
<?php
ini_set('display_errors', 'on');
session_start();
include('actions/database.php');
$afficher_profil = $bdd->query('SELECT * FROM utilisateur WHERE id = ?');
$afficher_profil->execute(array($_SESSION['id']));
$afficher_profil = $afficher_profil->fetchAll();
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Utilisateurs du site</title>
</head>
<body>
<div>Utilisateurs</div>
<table>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Voir le profil</th>
</tr>
<?php
foreach($afficher_profil as $ap){
?>
<tr>
<td><?= $ap['nom'] ?></td>
<td><?= $ap['prenom'] ?></td>
<td><a href="voir_profil.php?id=<?= $ap['id'] ?>">Aller au profil</a></td>
</tr>
<?php
} ?>
</table>
</body>