views:

49

answers:

1

i am trying to get player logic in place with those if statements player 1 fires 1st -> player 2 2nd then start over again (an user checks a box)then the unset removes the pieces from the board as they are hit

Parse error: syntax error, unexpected '(', expecting ']' in on line 93

the problem is this line of code:

               elseif($turn == 1){
        print "Player 2 Fired it is player 1's again";
        unset($Board[substr($value, 0, 1)][substr($value, 1, 1)]);
        $turn++

<?php
$box=$_POST["box"];
$fire=$_POST["fire"];
$turn=$_POST["turn"]; 
displayboard();





function displayboard(){




$Board = array
    (
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
        array(0,0,0,0,0,0,0,0),
    );

        $row = 0;
        print "<form>";
        print "<table border = 1>";
        while ($row < 8){ // Counts to 8. (from 0...7 = 8 times. 0 ... 8 = 9 times)
           print "<tr>";
           $row++;
           $col = 0; // reset column to 0 each time printing one row.

           while ($col < 8){
            print "<td>";
            if($Board[$row][$col] == 0)
            {
       $value=$row.$col;
                print "<input type=\"checkbox\" name=\"box[]\" value=\"$value\">";
                // Add \ before " otherwise it will treat as the end of the quote.

            }
            print "</td>";
            $col++;

           }

           print "</tr>";

        }
        print "</table>";
        print "</form>";

}








  if($fire == TRUE && isset($turn)){

         if ($turn == 2){
   print "Player 1 Fired it is player 2's turn to play <br>";
   unset($Board[substr($value, 0, 1)][substr($value, 1, 1)]);
   $turn--;
       print <<<HERE
    <form method="post">
      <input type ="submit" name="fire" value="fire">
      <input type="hidden" name="turn" value="$turn">
      </form>
HERE; 
   }elseif($turn == 1){
   print "Player 2 Fired it is player 1's again";
   unset($Board[substr($value, 0, 1)][substr($value, 1, 1)]);
   $turn++;
      print <<<HERE
   <form method="post">
     <input type ="submit" name="fire" value="fire">
     <input type="hidden" name="turn" value="$turn">
     </form>
HERE; 
   }elseif($fire == FALSE && $turn != 1){

   print <<<HERE
    <form method="post">
      <input type ="submit" name="fire" value="fire">
      <input type="hidden" name="turn" value="1">
      </form>
HERE;
  }


}






?>
+4  A: 

Make sure there is nothing after the ; which end the heredoc label:

HERE; 
     ^
there should not be anything here, not even space.
codaddict