GRooVeZ Posted April 9, 2012 Share Posted April 9, 2012 hi guys when a match is over, two result fields have to be edited the first update goes well but the second one is failing, not allways, sometimes it gives the loser xp, but not the winner (with two players) the script should give the winner 100 xp second 95, third 90,... only the first two controls at the end are working the thirth one is not, and its being used to make the first two so it is doing its job there ... <?php include("./includes/egl_inc.php"); $secure = new secure(); $secure->secureGlobals(); page_protect(); global $config; $matchidcheck = $_SESSION['matchid']; $maks = '100'; $players=mysql_query("SELECT playerid FROM ffa_points WHERE matchid='$matchidcheck' order by killsdeaths DESC"); while(list($playerid)=mysql_fetch_array($players)) { $playerspoints=mysql_query("SELECT points FROM members WHERE id='$playerid'"); while(list($points)=mysql_fetch_row($playerspoints)) { $userpoints = $points; } $newpoints = $userpoints + $maks; mysql_query("UPDATE members SET points = $newpoints WHERE id='$playerid'"); mysql_query("UPDATE ffa_points SET xppoints = $maks WHERE id='$playerid' and matchid='$matchidcheck'"); if ($totalxp > 51) { $maks = $maks - 5; } } $mes="$newpoints $points $maks All Results have been stored succesfully !! Thank You !"; return success($mes,'./ffamatchesarchive.php'); include("$config"); ?> any help would be greatly appreciated THX Quote Link to comment https://forums.phpfreaks.com/topic/260643-update-is-driving-me-crazy/ Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 Where is $totalxp being set? PS: this: while(list($points)=mysql_fetch_row($playerspoints)) { $userpoints = $points; } can be simplified to: $userpoints = mysql_result($playerspoints, 0); Quote Link to comment https://forums.phpfreaks.com/topic/260643-update-is-driving-me-crazy/#findComment-1335837 Share on other sites More sharing options...
GRooVeZ Posted April 9, 2012 Author Share Posted April 9, 2012 sorry my bad i changed the var name and forgot to edit before posting its not solving the problem it has to be if ($totalxp > 51) { $maks = $maks - 5; } and yea, i am using while loops while i shouldnt ... thx for showing me how Quote Link to comment https://forums.phpfreaks.com/topic/260643-update-is-driving-me-crazy/#findComment-1335852 Share on other sites More sharing options...
GRooVeZ Posted April 9, 2012 Author Share Posted April 9, 2012 and what is that 0 saying? Quote Link to comment https://forums.phpfreaks.com/topic/260643-update-is-driving-me-crazy/#findComment-1335879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.