为什么老报这个错误Parse error: syntax error, unexpected $end in C:\xampp\htdocs\dljm.php on line 53

<?php if($_SESSION[username]==""){?>
<style type="text/css">
.style1 {
font-size: 14px;
font-family: "宋体";
font-weight: normal;
}
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
color: #000000;
}
.style4 {
font-size: 12px;
font-family: "宋体";
}
.style6 {font-size: 13px; font-family: "宋体"; font-weight: normal; }
.style7 {font-size: 13px}
</style>
<table width="776" height="29" border="0" cellpadding="0" cellspacing="0" background="images/2.gif">
<FORM action="dl_ok.php" method=post name=dlform onsubmit="javascript:return yhdl_check(this);">
<tr>
<td width="76" align="center" valign="middle" class="style1"> </td>
<td width="65" height="24" align="center" valign="middle" class="style1"><div align="center" class="style1 style7">用户名:</div> </td>
<td width="106" height="25" valign="middle"><input name="username" type="text" id="username" size="12"></td>
<td width="66" align="left" valign="middle"><span class="style6">密  码:</span></td>
<td width="94" valign="middle"><input name="password" type="text" id="password" size="12"></td>
<td width="63" align="left" valign="middle"><input name="imageField" type="image" src="images/denglu.gif" width="45" height="19" border="0"></td>
<td width="201" align="left" valign="middle"><a href="zhuce.php"><img src="images/zhuce.gif" width="45" height="19" border="0"></a></td>
<td width="87" align="center" valign="middle"> </td>
</tr>
</form>
</table>
<?
}else{
?>
<table width="776" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="455">  <span class="style4"> <?php echo $username;?>已登录,欢迎您发表评论和回复主题!!</span></td>
<td width="80" height="25" align="center"><a href="zx_ok.php" class="style4">注销登录!</a></td>
</tr>
</table>
<?
}
?>
运行上面的代码就报Parse error: syntax error, unexpected $end in C:\xampp\htdocs\dljm.php on line 53这个错误提示

这个问题的原因是

PHP编码段开头的<?php 和 <? 不统一造成的。你可以看一下这段代码中第一个是这样写的"<?php" 而下面的两个是这样写的"<?",这个符号在整站中一定要统一才行。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-11-23
没有问题

<?php

if($_SESSION['username']=="")
{

?>
<style type="text/css">
.style1 {
font-size: 14px;
font-family: "宋体";
font-weight: normal;
}
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
color: #000000;
}
.style4 {
font-size: 12px;
font-family: "宋体";
}
.style6 {font-size: 13px; font-family: "宋体"; font-weight: normal; }
.style7 {font-size: 13px}
</style>
<table width="776" height="29" border="0" cellpadding="0" cellspacing="0" background="images/2.gif">
<FORM action="dl_ok.php" method=post name=dlform onsubmit="javascript:return yhdl_check(this);">
<tr>
<td width="76" align="center" valign="middle" class="style1"> </td>
<td width="65" height="24" align="center" valign="middle" class="style1"><div align="center" class="style1 style7">用户名:</div> </td>
<td width="106" height="25" valign="middle"><input name="username" type="text" id="username" size="12"></td>
<td width="66" align="left" valign="middle"><span class="style6">密 码:</span></td>
<td width="94" valign="middle"><input name="password" type="text" id="password" size="12"></td>
<td width="63" align="left" valign="middle"><input name="imageField" type="image" src="images/denglu.gif" width="45" height="19" border="0"></td>
<td width="201" align="left" valign="middle"><a href="zhuce.php"><img src="images/zhuce.gif" width="45" height="19" border="0"></a></td>
<td width="87" align="center" valign="middle"> </td>
</tr>
</form>
</table>
<?
}else{
?>
<table width="776" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="455"> <span class="style4"> <?php echo $username;?>已登录,欢迎您发表评论和回复主题!!</span></td>
<td width="80" height="25" align="center"><a href="zx_ok.php" class="style4">注销登录!</a></td>
</tr>
</table>
<?
}
?>本回答被网友采纳
第2个回答  2010-11-24
鄙视“网友推荐答案”,不要以为回复内容多就正确,其实关键的是“无BOM头”。另外你的文档的编码一定要指定,比如UTF-8还是GBK的
第3个回答  2010-11-24
好像只有这个 $_SESSION['username']==""
相似回答