I believe I have an error in my syntax, but I'm not sure where. I've looked here for how to insert data, and here for how to update data....
This is the snippet which updates/inserts the data (PHP)...
if ($is_edit === true) {
$update_query = "UPDATE `$blog_table` SET `title`=$title_value, `content`=$content_value WHERE $identifier";
$connection->query($update_query);
header('Location: .');
} elseif ($is_edit === false) {
$current_date = date('Y-m-d');
$add_entry_query = "INSERT INTO $blog_table (date, title, content, comments) VALUES ($current_date, $title_value, $content_value, '')";
$connection->query($add_entry_query);
header('Location: .');
}
I know the actual logic is functioning correctly, because I get the page is redirected when the logic is correct.
As far as I can tell, I have copied the syntax exactly, but I'm not getting any data added.
I know for a fact that $blog_table
and the assorted value variables are correct because I've echoed them to see if they were valid. I also use the exact same $blog_table
to view data on the same page with the same connection which works flawlessly.
What is the problem with my syntax?