If-else function in php wont work

<?php
if ($_SESSION['leveluser']=='user'{?>
<div id="header">
    <div id="menu">
      <ul>
        <li><a href=?rajaampat=info><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Home</a></li>
        <?php include "menu.php"; ?>
        <li><a href=logout.php><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Logout</a></li>
      </ul>
        <p>&nbsp;</p>
    </div>

  <div id="content">
        <?php include "content.php"; ?>
  </div>
<?php}elseif ($_SESSION['leveluser']=='admin'){?>
<div id="header">
    <div id="menu">
      <ul>
        <li><a href=?rajaampat=info><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Home</a></li>
        <?php include "menu2.php"; ?>
        <li><a href=logout.php><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Logout</a></li>
      </ul>
        <p>&nbsp;</p>
    </div>

  <div id="content">
        <?php include "content2.php"; ?>
  </div>';
<?php}else {?>
    <p><b>MAAF ANDA HARUS LOG IN do e</b></p>";
<?php}?> 

i keep getting this error : Parse error: syntax error, unexpected '?>' in C:\xampp\htdocs\WEB RAJA AMPAT\homedir\public_html\myadmin\administrator\media.php on line 98

Thx in advance for helping

edit : Cant find my answer in "PHP parse/syntax errors; and how to solve them? "

2 answers

  • answered 2018-07-11 05:28 Sambhaji Katrajkar

    In your code, check if condition, you have not closed parenthesis. Replace your if condition with following:

    Please change it

    if($_SESSION['leveluser']=='user'{?>
    

    to

    if($_SESSION['leveluser']=='user'){ ?>
    

  • answered 2018-07-11 05:31 Jordan Quartermain

    <?php
    if ($_SESSION['leveluser']=='user'){
    echo '<div id="header">'.
        '<div id="menu">'.
          '<ul>'.
            '<li><a href=?rajaampat=info><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Home</a></li>';
            include "menu.php";
            '<li><a href=logout.php><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Logout</a></li>'.
          '</ul>'.
            '<p>&nbsp;</p>'.
       '</div>'.
     '<div id="content">';
            include "content.php";
      echo '</div>';
    }
    elseif ($_SESSION['leveluser']=='admin'){
    echo '<div id="header">'.
        '<div id="menu">'.
          '<ul>'.
            '<li><a href=?rajaampat=info><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Home</a></li>';
            include "menu2.php";
            echo '<li><a href=logout.php><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Logout</a></li>'.
          '</ul>'.
            '<p>&nbsp;</p>'.
        '</div>'.
      '<div id="content">';
            include "content2.php";
      echo '</div>';
    }
    else {
      echo '<p><b>MAAF ANDA HARUS LOG IN do e</b></p>';
    }
    ?>