无法找到解析错误的解决方案:语法错误,意外情况'否则' (T_ELSE)

时间:2014-12-28 17:20:22

标签: php html

我有这段代码,在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:我在网站上搜索了同样的问题,但我不能

1 个答案:

答案 0 :(得分:2)

你的if之后有一个;,删除它,你就会很好

if("SELECT username FROM patient WHERE username='$username'");

应该是

if("SELECT username FROM patient WHERE username='$username'")

如果你将大括号{放在同一行

,会有所帮助