ohdang888 Posted March 23, 2008 Share Posted March 23, 2008 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 More sharing options...
toplay Posted March 24, 2008 Share Posted March 24, 2008 From the code posted, I don't see where you set $game !! Link to comment https://forums.phpfreaks.com/topic/97540-query-not-working/#findComment-499086 Share on other sites More sharing options...
ohdang888 Posted March 24, 2008 Author Share Posted March 24, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.