i try to update my database but i get error.
i have a table in mysql:
article_id article_title article_content article_timestamp img_url
and in my code :
if(isset($_SESSION['logged_in'])) {
// display add page
if(isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = nl2br($_POST['content']); // nl2br - Inserts HTML line breaks
before all newlines in a string
$image = $_POST['image'];
//$image = "admin/uploads/" . $_FILES['image']['name'];
$id = $_POST['article_id'];
if(empty($title) OR empty($content)) {
$error = 'All fields are required';
} else {
**$query = $pdo->prepare("UPDATE articles SET article_title = $title,
article_content = $content, img_url = $image WHERE article_id=$id");**
$query->execute();
header('Location: index.php');
}
}
?>
...
i try to write a variable but i get error why?
thank's...