From 65322d53842f9ee7e166970e5250f76c36fc3e6a Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Tue, 3 Feb 2009 19:28:36 -0800 Subject: [PATCH 1/1] 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. --- include/game.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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"; -- 2.17.1