是的,我的建議是使用括號。現在你的代碼基本上是這樣讀取的:
<?php
if($_SESSION['id']) {
echo '<div id="center" class="column">';
}
include("center.php");
echo'</div>
<div id="left" class="column">';
include("leftbar.php");
echo'</div>
<div id="right" class="column">';
include("rightbar.php");
echo '</div>';
} else {} <--- error is here because there is no open if statement since you didn't use brackets
echo '<h1>Staff please, <a href="index.php">login</a>
before accessing this page, no access to students.</h1>';
?>
請注意,由於您沒有使用括號,因此您的條件僅適用於以下代碼行。當解析器碰到else行時,如果else與其相關,則沒有開放條件。
您的代碼應該這樣寫:
<?php
if($_SESSION['id']) {
echo '<div id="center" class="column">';
include("center.php");
echo'</div><div id="left" class="column">';
include("leftbar.php");
echo'</div><div id="right" class="column">';
include("rightbar.php");
echo '</div>';
} else {
echo '<h1>Staff please, <a href="index.php">login</a> before accessing this page, no access to students.</h1>';
}
?>
你有沒有對括號的東西嗎? – 2013-03-14 22:19:41
你的鍵盤是否缺少'{'和'}'?因爲你的代碼確實。 – Mchl 2013-03-14 22:19:58