0

Here is my code. I'm new to php and just trying to edit a page using Kompozer. When I published the site back to the ftp server this error suddenly appeared on the page. Odd since I didn't even touch this code. (I have since touched the below code trying to fix it). Any help fixing this code would be much appreciated.

   <?php 
     if(isset($_SESSION["pkg_error"]))
   ?>
      <div class="error_msg_cont">
    <?php 
    foreach($_SESSION["pkg_error"] as $error)
    {
    echo $error. "<br>"
    }
    ?></div>
    <?php 
    if(isset($_SESSION["msg"]))
    {
    echo '<div class="error_msg_cont">'. $_SESSION["msg"] .'<div>'
    }
    ?>
legrandviking
  • 2,348
  • 1
  • 22
  • 29
programmingnewb
  • 129
  • 2
  • 9

2 Answers2

1

On these two lines:

echo $error. "<br>" }

echo '<div class="error_msg_cont">'. $_SESSION["msg"] .'<div>' }

You need a semicolon before the closing }.

Closing a PHP code block (?>) implies a semicolon, but closing a block of code within a PHP code block (}) does not.

Community
  • 1
  • 1
cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • I put them in as follows and get an error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' : echo $error. "
    "; } echo '
    '. $_SESSION["msg"] .'
    '; }
    – programmingnewb Jul 24 '13 at 21:44
1

you missed ; on :

echo $error. "<br>" }

and

echo '<div class="error_msg_cont">'. $_SESSION["msg"] .'<div>' }

Actually, the error is self-explained.

Raptor
  • 53,206
  • 45
  • 230
  • 366
  • I've tried putting the semicolon right before the }. It came out with another error that says: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' – programmingnewb Jul 24 '13 at 22:00
  • double check other codes. the problem is now elsewhere. – Raptor Jul 25 '13 at 03:31