I have been struggling with this , I couldn't get the query to , when I click the link to the post I have getting the id of the post, but whenever I add that's update query I always end up with error 500 work please kindly assist I will so much appreciate
<?php
if(!isset($_GET['id'])) {
header('Location: question.php');
exit();
} else {
$id = $_GET['id'];
}
//include database connection
require_once('./includes/connection.php');
if(!is_numeric($id)) {
header('Location: question.php');
}
$sql = "UPDATE posts SET title = :title, body = :body, category_id = :category_id WHERE post_id = :post_id";
// Prepare the query
$query = $db->prepare($sql);
$query->bindParam(':post_id', $id);
$query->execute();
?>
<?php include 'header.php';?>
<div><?php echo $id ?>
<?php include 'footer.php';?>
#0 /home/nairamar/domains/pals.com.ng/public_html/edit.php(33): PDOStatement->execute()
#1 {main}
thrown in /home/nairamar/domains/palg/public_html/edit.php on line 33
2022-12-15 15:40:51.416778 [NOTICE] [2689842] [T0] [105.112.188.163:5404-H3:BFCEDE7A777C8766-40#APVH_www.palsng:443] [STDERR] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /home/nairamar/domains/pal/public_html/edit.php:33
Stack trace:
#0 /home/nairamar/domains/palg/public_html/edit.php(33): PDOStatement->execute()
#1 {main}
thrown in /home/nairamar/domains/palg/public_html/edit.php on line 33
@thinkverse@sinnbeck thanks i got no error again, but when i try to update the post, all i am getting in the database is nothing , even the former post am editing has been cleared but no error