Not quite sure about this, but:
$problemID = (int)$problemID;
should be:
$problemID = intval($problemID);
Whenever something stops working, I always add
echo $sql;
Before calling mysql_query (); this way I can copy and paste the result into the SQL browser and see if it is correct.
EDIT: There was a different look, and as someone had previously escaped the SQL statement, I thought it was worth mentioning to try:
$sql = "UPDATE `problems` SET `votes` = `votes` {$vote} 1 WHERE `id` = {$problem_id}";
To:
$sql = "UPDATE `problems` SET `votes` = `votes` {".$vote."} 1 WHERE `id` = {$problem_id}";
but if all the SQL works, then why not try:
$sql = "UPDATE `problems` SET `votes` = `votes`+1 WHERE `id` = {$problem_id}";
since this is exactly what you are doing, then there is no need to pass the $ vote parameter.
Other simple debugging options:
print_r($_POST); // to show all the POSTED variables from a form print_r($_GET); // to show all the parameters from the URL
Bbloke
source share