Without prepared statements one can simply use "SET column=column+1" to increment a column. However I can't seem to get this working using prepared statements. If it's even possible, what am I doing wrong here?
<?php
$mysqli = new mysqli('host', 'user', 'pass', 'database');
$query = "UPDATE forums_topics SET posts=? WHERE id=?";
if ($stmt = $mysqli->prepare($query)) {
$stmt->bind_param('ii', 'posts' + 1, 1);
$stmt->execute();
$stmt->close();
}
$query = "UPDATE forums_topics SET posts=posts+? WHERE id=?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With