This question already has an answer here:
- How can I prevent SQL injection in PHP? 28 answers
Hello i get this error when i try to update my database columns
ERROR 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
<?php
$id = $_POST['id'];
$title = urlencode($_POST['title']);
$img = urlencode($_POST['img']);
$url = urlencode($_POST['url']);
$dec = urlencode($_POST['dec']);
mysqli_query($mysqli,"UPDATE posts SET title = $title, img = $img, url = $url, dec = $dec WHERE id = $id") or die(mysqli_error($mysqli));
?>
</div>