Getting a Parse error: syntax error, unexpected '}', expecting ',' or '; [closed]

醉酒当歌 提交于 2019-12-04 06:19:42

问题


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>'
    }
    ?>

回答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.




回答2:


you missed ; on :

echo $error. "<br>" }

and

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

Actually, the error is self-explained.



来源:https://stackoverflow.com/questions/17845162/getting-a-parse-error-syntax-error-unexpected-expecting-or

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!