I'm trying like 2 hours by now to figure out why my table won't update, and for the love of god, I can't figure it out. It's a simple poll setup. I've replace "UPDATE polls" with "UPDATE comments" and it updates comments without problems. Polls however just won't work so I guess the problem is in the database, but that's as far as I can get. Perhaps someone can help me out with this?
if (@$_POST['vote']) {
$check_votes = mysql_query ("SELECT votes FROM votes WHERE voter='$user' AND vote_subject='$subject'");
$numrows_votes = mysql_num_rows($check_votes);
if ($numrows_votes == 1) {
$error = "You already voted on this poll.";
}
else {
$check_polls = mysql_query ("SELECT * FROM polls WHERE poll_subject='$subject'");
while($row_polls = mysql_fetch_array($check_polls)) {
$vote1 = $row_polls['vote_one'];
$vote2 = $row_polls['vote_two'];
$numvote = 1;
$newvote1 = $vote1 + $numvote;
$newvote2 = $vote2 + $numvote;
$polloption = $_POST['choice'];
if ($polloption == "") {
$error = "You didn't select any option.";
}
else if ($polloption == "one") {
mysqli_query("UPDATE polls SET vote_one='$newvote1' WHERE poll_subject='$subject'");
}
else {
mysqli_query("UPDATE polls SET vote_two='$newvote2' WHERE poll_subject='$subject'");
}
}
}
}
And here is the form code:
<form action="" method="POST">
<h4>What question would you like to ask?</h4>
<input type='radio' name='choice' value='one'>
<?php echo "$newvote1"; ?>
<br>
<input type='radio' name='choice' value='two'>
<?php echo "$newvote2"; ?>
<p class="buttons">
<input type="submit" name="vote" value="VOTE">
</p>
</form>