One thing I’d suggest is trying to run your UPDATE statement directly on the database for starters to make sure you get the syntax correct (caveat: never in production, of course - but then, you’re not developing your PHP code in production, either. Are you.). Because if you can’t get it to work there, it probably won’t work when you try to translate your SQL to be used by PHP.
So, like other people already said, there are no square brackets in an UPDATE statement.
I only use MySQL, but I believe MariaDB is basically the same as it’s a fork. So here’s the corresponding MySQL UPDATE statement:
UPDATE recent_happenings SET recent_title = 'blah', recent_date = 'blah1', recent_pic_file = 'blah2' WHERE pic_number = 1;
(An INSERT
will use parentheses, and I wonder if you’re getting confused with that type of command.)
We don’t know whether you are using mysqli or pdo in your PHP. Here’s how you might do it using mysqli (for some reason I assume you’re using this):
$conn = mysqli_connect(host, username, password, database); // use your params
$sql = "UPDATE recent_happenings SET recent_title = '".
mysqli_real_escape_string($conn, $recent_title).
"', recent_date = '".mysqli_real_escape_string($conn, $recent_date).
"', recent_pic_file = '".
mysqli_real_escape_string($conn, $recent_pic_file).
"' WHERE pic_number = '".
mysqli_real_escape_string($conn, $pic_number).
"'";
mysqli_query($conn, $sql);
It looks horrible, and it is horrible. mysqli_real_escape_string
will usually be required to make the SQL work with your variables - it rewrites strings that have special characters so that they will be read correctly by the database machinery.
Sometimes you can get away without mysqli_real_escape_string
(like for quick and dirty testing). But it won’t prevent SQL injection attacks. So, like @benanamen recommended, learn to use PDO and prepared statements.