title: query does all rows correct except for row 9
body: <p>this is the code. whenever i input data it works fine. it counts every row correctly EXCEPT for game #9. every single game is counted correctly but game #9. ive sat through and asked 3 people for help. now im turning to you to help me figure out why this is happening.</p>
  
  <p>this is the code:</p>
  
  <pre><code>&lt;?php
  
  include ("../conn_inc.php");
  include ("../conn_inc_pdo.php");
  require_once ('auth.php');
  
  $game_id= $_POST['game_id'];
  $resultat= $_POST['namn'];
  $lag1=substr($resultat, 0,1);
  $lag2=substr($resultat, 2,1);
  
  
  if ($lag1&gt;$lag2){
      $tips="1";
  }
  if ($lag1&lt;$lag2){
      $tips="2";
  }
  if ($lag1==$lag2){
      $tips="x";
  }
  
  //echo $tips;
  
      //------------------FIND ALL ALREADY POSTED GAMES---------------\\
  
      $sql2 = $pdo-&gt;prepare("SELECT game_id FROM vm2014res WHERE :game_id = game_id");
      $sql2-&gt;execute(array(':game_id' =&gt; $game_id));
  
      if ($sql2-&gt;rowCount() == 0) {
  
          //------ IRRELEVANT TEST CODE 3 LINES DOWN-----\\
          echo $game_id;
          echo $resultat;
          echo "&lt;br&gt;";
  
  
             //----------- INSERT THE VALUE OF THE GAME IF IT DOESNT EXIST -------\\
              $q = "INSERT INTO vm2014res (game_id, resultat, added)  VALUES (:game_id, :resultat, CURRENT_TIMESTAMP)";
              $query = $pdo-&gt;prepare($q);
              $query-&gt;execute(array(
                  ':game_id' =&gt; $game_id,
                  ':resultat' =&gt; $resultat
                  ));
  
                       //------------------CHECK IF YOU SHOULD BE GETTING POINTS FOR A CORRECT GUESSED RESULT---------------\\
              $SQL = $pdo-&gt;prepare("SELECT * FROM vm2014 WHERE game_id = :game_id AND resultat = :resultat");
              $SQL-&gt;execute(array(':game_id' =&gt; $game_id, ':resultat' =&gt; $resultat));
              $r = $SQL-&gt;fetchAll(PDO::FETCH_ASSOC);
              foreach($r as $row){    
  
  
                 $bet_id = $row['bet_id'];
                 $game_id = $row['game_id'];
                 $tips = $row['tips'];
                 $resultat = $row['resultat'];
                 $namn = $row['namn'];
                 $points = $row['points'];
  
                 //-------- ALL ECHOS DOWN HERE ARE IRRELEVANT----------\\
                 echo $bet_id;
                 echo $game_id;
                 echo $tips;
                 echo $resultat;
                 echo $namn;
                 echo $points;
                 echo "&lt;br&gt;";
                 $points=$points+2;
                 echo $points;
  
      //------------- UPDATE THE POINTS GOTTEN (2 POINTS)---------\\
  
              $sql2 = $pdo-&gt;prepare("UPDATE vm2014 SET points = :points WHERE bet_id = :bet_id");
              $sql2-&gt;execute(array(':points' =&gt; $points,
              ':bet_id' =&gt; $bet_id
              ));
  
              }
  
              //------------------CHECK IF YOU SHOULD BE GETTING POINTS FOR RIGHT GUESSED GAME---------------\\
              $SQL = $pdo-&gt;prepare("SELECT * FROM vm2014 WHERE game_id = :game_id AND tips = :tips");
              $SQL-&gt;execute(array(':game_id' =&gt; $game_id, ':tips' =&gt; $tips));
              $r = $SQL-&gt;fetchAll(PDO::FETCH_ASSOC);
              foreach($r as $row){    
  
  
                 $bet_id = $row['bet_id'];
                 $game_id = $row['game_id'];
                 $tips = $row['tips'];
                 $resultat = $row['resultat'];
                 $namn = $row['namn'];
                 $points = $row['points'];
  
               //-------IRRELEVANT ECHOS DOWN HERE--------\\
                 echo $bet_id;
                 echo $game_id;
                 echo $tips;
                 echo $resultat;
                 echo $namn;
                 echo $points;
                 echo "&lt;br&gt;";
                 $points=$points+1;
                 echo $points;
  
      //----------------- UPDATE YOUR POINTS IF YOU SHOULD BE GETTING POINTS FOR THE GAME----\\
  
              $sql2 = $pdo-&gt;prepare("UPDATE vm2014 SET points = :points WHERE bet_id = :bet_id");
              $sql2-&gt;execute(array(':points' =&gt; $points,
              ':bet_id' =&gt; $bet_id
              ));
  
              }
  
      } else {
          //-----------------POST WHEN THE GAME RESULT WAS ADDED TO THE DB-------\\
              $SQL6 = $pdo-&gt;prepare("SELECT * FROM vm2014res WHERE game_id = :game_id");
              $SQL6-&gt;execute(array(':game_id' =&gt; $game_id));
              $ra = $SQL6-&gt;fetchAll(PDO::FETCH_ASSOC);
              foreach($ra as $row){ 
  
                 $game_id = $row['game_id'];
                 $resultat = $row['resultat'];
                 $added = $row['added'];
  
          echo "Resultatet är redan registrerat. Det registrerades: &lt;strong&gt;" . $added . "&lt;/strong&gt; och det vart &lt;strong&gt;" . $resultat . "&lt;/strong&gt; i matchen.";
              }
      }
  </code></pre>
  
  <p>ive included the entire part of the code because i dont know where the wrong part of the code is. it should be in the part which is followed by: </p>
  
  <pre><code>//------------------Kolla om du ska få poäng för ditt tips---------------\\
  </code></pre>
  
  <p>but i cant see the problem.</p>
  
  <p>im inputting 2-1 into game 9. and this is the input to the database: (i dont know how to make a table of this on this website)</p>
  
  <pre>
      bet_id  game_id tips    resultat    name      poäng 
      9           9   1       2-1         Player 1  2 
      57          9   x       1-1         Player 2  0 
      105         9   x       1-1         Player 3  0 
      153         9   1       2-0         Player 4  0 
      201         9   1       2-1         Player 5  2 
      249         9   1       3-0         Player 6  0 
      297         9   x       1-1         Player 7  0 
      345         9   x       0-0         Player 8  0 
      393         9   2       0-1         Player 9  1 
      441         9   1       1-0         Player 10 0 
      489         9   2       0-3         Player 11 1 
      537         9   x       0-0         Player 12 0 
      585         9   x       1-1         Player 13 0 
      633         9   1       2-0         Player 14 0 
      681         9   2       1-2         Player 15 1 
      729         9   2       0-1         Player 16 1 
      777         9   x       1-1         Player 17 0 
      825         9   1       3-0         Player 18 0 
      873         9   2       2-3         Player 19 1 
      921         9   2       0-1         Player 20 1 
      969         9   x       2-2         Player 21 0 
      1017        9   x       2-2         Player 22 0 
      1065        9   2       2-1         Player 23 3 
      1113        9   x       0-0         Player 24 0 
      1161        9   2       1-1         Player 25 1 
  </pre>
  
  <p>and as you can see, some players are getting points for being wrong. some are getting points for a correct result, but not getting for guessing who won the game.</p>
  
  <p>can someone please help me figuring out whats wrong?</p>