GRooVeZ Posted April 8, 2012 Share Posted April 8, 2012 hi, i wrote a pointsystem for a league, everything is working good untill i do a certain math action this is the piece of code where it goes wrong $playerkills = '0'; $playerdeaths = '0'; $players3=mysql_query("SELECT playerid,matchid,roundid,kills,deaths FROM ffa_results WHERE playerid='$playeridcheck' and matchid='$matchidcheck'"); while(list($playerid3,$matchid,$roundid,$kills,$deaths)=mysql_fetch_row($players3)) { $playerkills = ($playerkills + $kills); $playerdeaths = ($playerdeaths + $deaths); } $playerkillsdeaths = ($playerkills - $playerdeaths); $matchtypecheck=mysql_query("SELECT type FROM ffa_matches WHERE id='$matchidcheck'"); while(list($type)=mysql_fetch_row($matchtypecheck)) { $matchtype = $type; } $matchskilllvlchecker=mysql_query("SELECT skill FROM ffa_matches WHERE id='$matchidcheck'"); while(list($skill)=mysql_fetch_row($matchskilllvlchecker)) { $matchskill = $skill; } $skilllvlchecker=mysql_query("SELECT ffapoints FROM members WHERE id='$playeridcheck'"); while(list($skill2)=mysql_fetch_row($skilllvlchecker)) { $playerskill = $skill2; } $schaal = round(($playerskill - $matchskill)*7); $playerpoints = ($playerkillsdeaths - $schaal); >>>>>>>>>>>>>>>>>>>>>>> $playerpoints2 = ($playerkillsdeaths - $playerpoints); $insertSite_sql2 = "INSERT INTO ffa_points (matchid,matchtype,playerid,kills,deaths,killsdeaths,points) VALUES ($matchidcheck,$matchtype,$playeridcheck,$playerkills,$playerdeaths,$playerkillsdeaths,$playerpoints2)"; $insertSite2= mysql_query($insertSite_sql2); } everything works good untill the >>>>>>>> line, all math before that is working, i can insert all of those vars in the last field in the points collumn. but from the moment i do playerpoints - playerkillsdeaths it retursn me the $schaal variable, i dont have a clue why, but it does, for some kind of reason i cannot contracts those two vars .. has this something todo with the line before the >>>> line? who can explain this to me? thanks allot in advance Quote Link to comment https://forums.phpfreaks.com/topic/260540-wierd-counting-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 8, 2012 Share Posted April 8, 2012 You forgot to tell us the actual values your code is using, what result you got, what result you expected, and exactly how you observed that the result is not what you expected. Also, why are you looping over query results where there is only one row in each result set and executing two separate queries against the ffa_matches table just to get the type and skill values from the same row? Quote Link to comment https://forums.phpfreaks.com/topic/260540-wierd-counting-problem/#findComment-1335317 Share on other sites More sharing options...
GRooVeZ Posted April 8, 2012 Author Share Posted April 8, 2012 hey man i got this thing working now, but to answer ur question im a php noob, and im more like copy pasting and puzzling then writing code myself anyway ive been doing some research and this piece of code is really easy, but im failing ... can u tell me what im doing wrong? i just want to exec a query and then check if there was a result $query10 = "SELECT points FROM ffa_rankings WHERE playerid='$playeridcheck' and gameid='$gametype' and typeid='$matchtype'"; $result10 = mysql_query($query10); $row10 = mysql_fetch_array($result10); if ($row10) { operation here } else { operation here } Quote Link to comment https://forums.phpfreaks.com/topic/260540-wierd-counting-problem/#findComment-1335438 Share on other sites More sharing options...
chriscloyd Posted April 8, 2012 Share Posted April 8, 2012 What is happening when you run this code? <?php $query10 = "SELECT `points` FROM `ffa_rankings` WHERE playerid = '{$playeridcheck}' and gameid = '{$gametype}' and typeid = '{$matchtype}'"; $result10 = mysql_query($query10); $row10 = mysql_fetch_array($result10); if ($row10) { // } else { // } Quote Link to comment https://forums.phpfreaks.com/topic/260540-wierd-counting-problem/#findComment-1335477 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.