2014-10-19 4 views
-1

프로그래밍 및 PHP에 대한 완전한 초보자입니다. 예기치 않은 파일 끝이 있다는 오류를 던지고 코드가 누락 된 부분을 볼 수 없거나 거기해서는 안된다. 누구든지 그것을 발견 할 수 있습니까?PHP 구문 분석 오류 - 예기치 않은 파일 끝

<html> 
 
<head> 
 
<title><?php echo $firstname; ?> <?php echo $lastname; ?>'s Profile</title> 
 
</head> 
 
<body> 
 
<?php 
 

 
if (isset($_GET['username'])){ 
 
    \t $username = $_GET['username']; 
 
    mysql_connect("localhost","root", "") or die ("Could not connect to the server"); 
 
    mysql_select_db("users") or die ("That database could not be found."); 
 
\t $userquery = mysql_query("SELECT * FROM users WHERE username='$username'") or die ("The query could not be completed, please try again later."); 
 
\t if(mysql_num_rows($userquery) !=1){ 
 
\t \t die ("That user could not be found."); 
 
\t } 
 
\t while($row = mysql_fetch_array($userquery, MYSQL_ASSOC)) { 
 
\t \t $firstname = $row['firstname']; 
 
\t \t $lastname = $row['lastname']; 
 
\t \t $email = $row['email']; 
 
\t \t $dbusername = $row['dbusername']; 
 
\t \t $access = $row['access']; 
 
\t \t } 
 
\t \t if($username != $dbusername){ 
 
\t \t \t die ("There has been a fatal error, please try again."); \t \t 
 
\t \t } 
 
\t 
 
\t \t if($access == 1) { 
 
\t \t \t $access = "Level 1 User"; 
 
\t \t } else 
 
\t \t \t if($access == 2) { 
 
\t \t \t \t $access = "Level 2 User"; 
 
\t \t \t } \t else 
 
\t \t \t \t \t if($access == 3) { 
 
\t \t \t \t \t \t $access = "Level 3 User"; 
 
\t \t \t \t \t } else 
 
\t \t \t \t \t \t if($access == 4) { 
 
\t \t \t \t \t \t \t $access = "Administrator."; 
 
\t \t \t \t \t \t } else die ("This user has an access level beyond the realms of possibility. Beware."); 
 
\t 
 
\t \t \t \t \t 
 

 
?> 
 

 
<h2><?php echo $firstname; ?> <?php echo $lastname; ?>'s Profile</h2><br /> 
 
<table> 
 
\t <tr><td>Firstname:</td><td><?php echo $firstname; ?></td></tr> 
 
    <tr><td>Lastname:</td><td><?php echo $lastname; ?></td></tr> 
 
    <tr><td>email:</td><td><?php echo $email; ?></td></tr> 
 
\t <tr><td>dbusername:</td><td><?php echo $dbusername; ?></td></tr> 
 
\t <tr><td>access:</td><td><?php echo $access; ?></td></tr> 
 
</table> 
 
</body> 
 
</html>

+0

어디 WHILE 루프 끝을합니까? – Jocelyn

답변

0

이 필요 코드 블록}는 폐쇄 될 경우 주요인가

<html> 
 
<head> 
 
<title><?php echo $firstname; ?> <?php echo $lastname; ?>'s Profile</title> 
 
</head> 
 
<body> 
 
<?php 
 

 
if (isset($_GET['username'])){ 
 
    \t $username = $_GET['username']; 
 
    mysql_connect("localhost","root", "") or die ("Could not connect to the server"); 
 
    mysql_select_db("users") or die ("That database could not be found."); 
 
\t $userquery = mysql_query("SELECT * FROM users WHERE username='$username'") or die ("The query could not be completed, please try again later."); 
 
\t if(mysql_num_rows($userquery) !=1){ 
 
\t \t die ("That user could not be found."); 
 
\t } 
 
\t while($row = mysql_fetch_array($userquery, MYSQL_ASSOC)) { 
 
\t \t $firstname = $row['firstname']; 
 
\t \t $lastname = $row['lastname']; 
 
\t \t $email = $row['email']; 
 
\t \t $dbusername = $row['dbusername']; 
 
\t \t $access = $row['access']; 
 
\t \t } 
 
\t \t if($username != $dbusername){ 
 
\t \t \t die ("There has been a fatal error, please try again."); \t \t 
 
\t \t } 
 
\t 
 
\t \t if($access == 1) { 
 
\t \t \t $access = "Level 1 User"; 
 
\t \t } else 
 
\t \t \t if($access == 2) { 
 
\t \t \t \t $access = "Level 2 User"; 
 
\t \t \t } \t else 
 
\t \t \t \t \t if($access == 3) { 
 
\t \t \t \t \t \t $access = "Level 3 User"; 
 
\t \t \t \t \t } else 
 
\t \t \t \t \t \t if($access == 4) { 
 
\t \t \t \t \t \t \t $access = "Administrator."; 
 
\t \t \t \t \t \t } else die ("This user has an access level beyond the realms of possibility. Beware."); 
 
}//THIS IS WHAT IS MISSING 
 
\t \t \t \t \t 
 

 
?> 
 

 
<h2><?php echo $firstname; ?> <?php echo $lastname; ?>'s Profile</h2><br /> 
 
<table> 
 
\t <tr><td>Firstname:</td><td><?php echo $firstname; ?></td></tr> 
 
    <tr><td>Lastname:</td><td><?php echo $lastname; ?></td></tr> 
 
    <tr><td>email:</td><td><?php echo $email; ?></td></tr> 
 
\t <tr><td>dbusername:</td><td><?php echo $dbusername; ?></td></tr> 
 
\t <tr><td>access:</td><td><?php echo $access; ?></td></tr> 
 
</table> 
 
</body> 
 
</html>

+0

감사합니다! 나는 그 지역에 있다고 느꼈지만 나는 그것을 발견 할 수 없었다. – TFrost

+0

답변을 수락하십시오 – muimota

관련 문제