title: Troubleshooting "Parse error: syntax error, unexpected T_ELSE" in nested if blocks
body: <p>I have the following code on my website:</p>
  
  <pre><code>&lt;?php
  $loggedout = $_GET["loggedout"];
  if ($loggedout=="true") { 
  echo '&lt;body class="slider-header" onload="Modalbox.show(\'/data/loggedout\',{width: 576, title: \'Logged Out\'}); return false;"&gt;'; else { 
  if (isset($_COOKIE["hide"]))
    echo '&lt;body class="slider-header"&gt;';
  else
    echo '&lt;body class="slider-header" onload="Modalbox.show(\'/data/surveyinvite\',{width: 576, title: \'Website Survey\'}); return false;"&gt;';
  }; ?&gt;
  </code></pre>
  
  <p>What this should do is determine if <code>$loggedout</code> equals true and, if so, display <code>/data/loggedout</code>.  If <code>$loggedout</code> is not true (or not present), it should then go on to determine if the cookie <code>hide</code> exists.  If the cookie does exist, there should be no <code>onload</code> and if the cookie does not exist, it should display <code>/data/surveyinvite</code>.</p>
  
  <p>However, I get the following error when going to my page: </p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected
    T_ELSE in
    /home/briefs/public_html/index.php on
    line 16</p>
  </blockquote>
  
  <p>Line 16 is</p>
  
  <pre><code>echo '&lt;body class="slider-header" onload="Modalbox.show(\'/data/loggedout\',{width: 576, title: \'Logged Out\'}); return false;"&gt;'; else { 
  </code></pre>
  
  <p>I have determined that issue is somewhere in the following (if I get rid of it, <code>$loggedout</code> works as expected):</p>
  
  <pre><code>if (isset($_COOKIE["hide"]))
    echo '&lt;body class="slider-header"&gt;';
  else
    echo '&lt;body class="slider-header" onload="Modalbox.show(\'/data/surveyinvite\',{width: 576, title: \'Website Survey\'}); return false;"&gt;';
  }; 
  </code></pre>
  
  <p>Where is the issue in this code?</p>