Jump to content

query not working


ohdang888

Recommended Posts

this is my rating, system, fairly simple....

 

There's no errors shown, but when i look at the new values in PhpMyAdmin, it didn't update it.

 

 

<?php
$vote = mysql_real_escape_string($_POST['vote']);

$result = mysql_query("SELECT `score`, `votes` FROM `vote` WHERE `game` = '{$game}' ")or die(mysql_error())
$poll = mysql_fetch_array($result);

$new_score = $poll['score'] + $vote;
$new_vote_total = $poll['votes'] + 1;
$a = $new_score/$new_vote_total;
$new_rating = round($a, 2);

mysql_query("UPDATE `vote` SET `score` = (score + {$vote}), `votes`= (votes + 1), `rating`='{$new_rating}' WHERE `game`='{$game}' ") or die(mysql_error());
?>

 

and the vote script is:

<form action="action.php?action=vote&game=<?php echo $game ?>" method="POST">
<input type="radio" name="vote" value="1"> 1<br>
<input type="radio" name="vote" value="2"> 2<br>
<input type="radio" name="vote" value="3"> 3<br>
<input type="radio" name="vote" value="4"> 4<br>
<input type="radio" name="vote" value="5"> 5<br>
<input type="submit" value="Vote!">
</form>

 

thanks for your help!

Link to comment
https://forums.phpfreaks.com/topic/97540-query-not-working/
Share on other sites

sorry.... thats up higher, i get it from the url...

 

but i know this function works fine, because it directs me back to the game page, it just isn't updating.

function sql_quote($data) {
  if (get_magic_quotes_gpc()) {
  $data = stripslashes($data);
  }

return addslashes($data);
}

$game = mysql_real_escape_string(sql_quote($_GET['game']));

Link to comment
https://forums.phpfreaks.com/topic/97540-query-not-working/#findComment-499087
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.