-1

I have the following PHP code, and the error that I get when I try to run it, says that there is an unexpected EOF error on line 33, which is the final line with the </html> tag on it. I have checked for any extra spaces, and there are none. I cannot figure out what the error might be.

<body>
<?php
$numOfTeams = " ";

    if($numOfTeams > 2)
    {
        include($numOfTeams);
    }

    $results = $query->fetchAll();
?>

<table align="center" border="1px" style="width: 300px" color="black">
<th>Club Name</th>    <th>Number of Teams</th>
<tr>
    <?php
    while($row = $query->fetch()) {?>
    <td><?php echo $row['cid']; ?></td>
    ?>
</tr>  
<tr>
    <?php
    while($row = $query->fetch()) {?>
    <td><?php echo $row['numOfTeams'];?></td>
    ?>
</tr>
</table>
</body>
</html>

I'm not sure why there is an error on that line since from what I can see, there is no actual code on that line.

user83024
  • 11
  • 3
  • 3
    You are simply not closing the `while` loops.. In the future use the alternative style for loops and conditions inside HTML code. – Spoody Apr 05 '18 at 18:49
  • Try not to miss semicolons. – Tripp Kinetics Apr 05 '18 at 18:50
  • 1
    Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Nigel Ren Apr 05 '18 at 18:56
  • Its not a semicolon @TrippKinetics, its a right curly brace being missed after the while loop. – castis Apr 05 '18 at 19:02

2 Answers2

3

you forget to close } of while loops

use this better:

<?php
while($row = $query->fetch()) 
{
  echo '<td>' . $row['cid'] . '</td>';
}

while($row = $query->fetch()) 
{
 echo '<td>' . $row['numOfTeams'] . '</td>';
}
Khaled Alam
  • 885
  • 7
  • 12
0

You aren't closing your bracers correctly and you have a hanging empty closing php tag...

<tr>
    <?php
    while($row = $query->fetch()) {?>      <-- Bracer never closed
    <td><?php echo $row['cid']; ?></td>
    ?>                                     <-- Hanging php closing tag
</tr>  
lloydpick
  • 1,638
  • 1
  • 18
  • 24