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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.