First thing to say is I am somewhat new to the whole SQL prepared statment thing. Here is my issue, when I try and count the number of times a user has rated a post I am not getting a response, instead I get an odd error. Any help would be appreciated.
$query = "SELECT COUNT(*) FROM `rate` WHERE `userID`=? AND `postID`=?";
if($stmt = $connection->prepare($query)){
$stmt->bind_param("ii", $id, $post_id);
$stmt->execute();
$stmt->bind_result($count);
$stmt->fetch();
echo $count;
} else {
echo $connection->error;
}
And the error given by the echo $connection->error is: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1