From: Arun Persaud Date: Wed, 4 Feb 2009 03:28:36 +0000 (-0800) Subject: BUGFIX: for loop over a possible undefined variable X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=65322d53842f9ee7e166970e5250f76c36fc3e6a BUGFIX: for loop over a possible undefined variable for the first game in a session there is no score to display yet, need to check if the score variable is empty or not before I loop over it. --- diff --git a/include/game.php b/include/game.php index 377d0aa..845a562 100644 --- a/include/game.php +++ b/include/game.php @@ -215,12 +215,23 @@ if($session) $finalscore = array_pop($tmpscore); $finalscore = $finalscore['players']; - echo "
Score: \n"; - foreach($finalscore as $user=>$value) + echo "
"; + if($finalscore) + { + echo "Score: \n"; + /* output the final score on the front page */ + foreach($finalscore as $user=>$value) + { + $name = DB_get_name('userid',$user); + echo " ".substr($name,0,2).": $value "; + } + } + else { - $name = DB_get_name('userid',$user); - echo " ".substr($name,0,2).": $value "; + /* first game, no score yet */ + echo " "; } + echo format_score_table_html($score,$myid); echo "
\n";