0

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';?>
Praise Adeala
  • 78
  • 1
  • 1
  • 8
  • 2
    Looks like you're only binding `:post_id` and not the rest of the parameters such as `:title` etc.. although I'm sure there's other things which may be the issue. This is the one that stands out to me. – IsThisJavascript Dec 15 '22 at 15:23
  • 1
    Also, I should add that I think `header()` still allows the continuation of a script. You should kill php after a `header()` call with an `exit();`. – IsThisJavascript Dec 15 '22 at 15:24
  • Configure error reporting, read error messages and fix errors. – Your Common Sense Dec 15 '22 at 15:41

0 Answers0