The answer is (fairly) a simple one and it may sound rather odd to you, but that in a sense meant that your query did in fact execute.
Now, the reason you're getting that 1
as per the right syntax to use near '1'
(error) message, is that you used mysqli_query()
twice, right in here:
$edit = mysqli_query($con, "
^^^^^^^^^^^^ Here
UPDATE blog_posts
SET post_title='$post_title'
, content='$content'
, author_name='$author_name'
, category='$category'
, post_date=now()
, image='$image_name'
WHERE post_id='$id'
");
if(mysqli_query($con, $edit)){
^^^^^^^^^^^^ and here
echo "date updated successfully";
}
What you need to do is to change that if
statement to:
if($edit){
// handle your method here.
}
Btw, you're open to a serious sql injection; use a prepared statement if you value your work and userbase.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…