是的,我的建议是使用括号。现在你的代码基本上是这样读取的:
<?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