Search code examples
phpparse-error

Parse error: syntax error, unexpected T_ENDIF in /home/comp3170-020/public_html/assignment1/index.php on line 44


     <?php
    if (!empty($_SESSION['err'])): ?>
    <tr>
      <td width="220" class="content_l" > <font color = "ff0000"> 
       <?php foreach ($_SESSION['err'] as $err): echo $err.'<br>';  ?> </td>
     </tr>
     <?php
     endif;
     unset($_SESSION['err'];
     ?>

Keep getting this error, cant see anything wrong.


Solution

  • It should be this way:

       <?php
    if (!empty($_SESSION['err'])):
    ?>
    <tr>
      <td width="220" class="content_l" > <font color = "ff0000"> 
    
       <?php foreach ($_SESSION['err'] as $err){ echo $err.'<br>'; }?> </td>
    
     </tr>
    
     <?php
     endif;
     unset($_SESSION['err']);
     ?>