我有这段代码,在ELSE
中它给了我这个错误Parse error: syntax error, unexpected 'else' (T_ELSE)
,当我算上{}
时看起来很好。
你可以帮我解决这个问题吗?
谢谢
function showProfile($username)
{
if (file_exists("$username.jpg"))
echo "<img src='$username.jpg' align='left' />";
$result = queryMysql("SELECT fname,lname,gender,age,disease,spid FROM patient WHERE username='$username' UNION SELECT fname,lname,gender,age,specialty,doctorID FROM doctor WHERE username='$username'");
if (mysql_num_rows($result))
{
$row = mysql_fetch_row($result);
echo stripslashes($row[0]) . "<br/>";
echo stripslashes($row[1]) . "<br clear=left /><br />Gender: ";
echo stripslashes($row[2]) . "<br clear=left /><br />Age: ";
if("SELECT username FROM patient WHERE username='$username'");
{
echo stripslashes($row[3]) . "<br clear=left /><br />Disease: ";
echo stripslashes($row[4]) . "<br clear=left /><br />SPID: ";
echo stripslashes($row[5]) . "<br clear=left /><br />";
}
else
{
echo stripslashes($row[3]) . "<br clear=left /><br />Specialty: ";
echo stripslashes($row[4]) . "<br clear=left /><br />Doctor ID: ";
echo stripslashes($row[5]) . "<br clear=left /><br />";
}
}
}
PS:我在网站上搜索了同样的问题,但我不能
答案 0 :(得分:2)
你的if之后有一个;
,删除它,你就会很好
if("SELECT username FROM patient WHERE username='$username'");
应该是
if("SELECT username FROM patient WHERE username='$username'")
如果你将大括号{
放在同一行