I am trying to use a menu link (index.php?) for my pages, so that when the link is selected the information from a database is added to the page. However, I get the following error message:
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 MariaDB server version for the right syntax to use near ‘’` WHERE id = .id’ at line 1 in C:\xampp\htdocs\testsite\index.php:24 Stack trace: #0 C:\xampp\htdocs\testsite\index.php(24): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\testsite\index.php on line 24
Here is the code:
<?php
// query database
$pdo_statement = $conn->prepare("SELECT * FROM pages'` WHERE id = .id");
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$pdo_statement->bindParam(':id', $id, PDO::PARAM_INT);
$pdo_statement->execute();
$result = $pdo_statement->fetchAll();
?>
<!-- display data -->
<?php
if(!empty($result)) {
foreach($result as $row) {
?>
<td class="navItem"><a href="index.php?id=$row['id']">
<?php echo $row["menuheader"]; ?>
</a></td>
<?php
}
}
?>
Any help will be appreciated.