2014-02-21 99 views
-5

誰能明白爲什麼我可能會得到以下錯誤:在PHP代碼文件意外結束

syntax error, unexpected end of file in D:\wamp\www\main\index.php on line 70

我也很感激,如果任何人都可以提出一個很好的編輯器,是PHP語法更好。

<?php 
    $mysql_host='localhost'; 
    $mysql_user='root'; 
    $mysql_pass=''; 
    $error="Not getting connected"; 

    mysql_connect($mysql_host,$mysql_user,$mysql_pass) || die(); 
    mysql_selectdb('registration'); 

    if(!isset($_POST['username'])&&!isset($_POST['password'])) 
    { 
     $error="no values has been set"; 
    } 
    else 
    { 
     $username=$_POST['username']; 
     $password=$_POST['password']; 
     $password_hash=md5($password); 
     $query="SELECT * 'username','password' FROM 'registration' where 'username'='$username' AND 'password'='$password_hash'"; 

     if($query_run=mysql_query($query)) 
     { 
      $query_num_rows=mysql_num_rows($query_run); 

      if($query_num_rows==0) 
      { 
       echo "error"; 
      } 
      else 
      { 
       echo "LOGGED IN"; 
      } 
?> 



<!DOCTYPE html>  
<html> 
    <head> 
    <title>Get to know yourself</title> 

    <!-- Latest compiled and minified CSS --> 
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> 

<!-- Optional theme --> 
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> 

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> 

<!-- Latest compiled and minified JavaScript --> 
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> 
</head> 
    <body> 
    <div class="row"> 
     <div class="col-md-12"> 
     <form action="index.php" method="POST" name="Registration"> 
      <input type="text" value="Name" Name="username"> 
       <input type="password" value="passowrd" Name="password"> 
        <input type="submit"> 
     </form> 
     </div> 
    </div> 



     </body> 

</html> 
+2

這篇文章就像一個特製的downvote磁鐵。 – sbichenko

+0

您可能缺少';','}或''''。仔細檢查你的代碼。 –

+2

我想知道是否使用用戶名''OR 1 = 1 - '登錄我? –

回答

2

您需要關閉兩個大括號..!

} 
else 
{ 
    echo "LOGGED IN"; 
} 
} //<--- Here (for your `if` statement) 
} //<--- and Here (for your `else` statement) 

?> 
0

你就失去了右大括號的的if/then是如果($ query_run =請求mysql_query($查詢))

if($query_run=mysql_query($query)) 
    { 
     $query_num_rows=mysql_num_rows($query_run); 
     if($query_num_rows==0) 
     { 
      echo "error"; 
     } 
     else 
     { 
      echo "LOGGED IN"; 
     } 
    } 
} 

我有一種感覺,這個問題將很快被關閉,雖然...祝你好運

1
it will work the problem is u dint close the if loop 


<?php 


    $mysql_host='localhost'; 
    $mysql_user='root'; 
    $mysql_pass=''; 
    $error="Not getting connected"; 

    mysql_connect($mysql_host,$mysql_user,$mysql_pass) || die(); 
    mysql_selectdb('registration'); 

    if(!isset($_POST['username'])&&!isset($_POST['password'])) 
    { 
     $error="no values has been set"; 
    } 
    else 
    { 
     $username=$_POST['username']; 
     $password=$_POST['password']; 
     $password_hash=md5($password); 
     $query="SELECT * 'username','password' FROM 'registration' where 'username'='$username' AND 'password'='$password_hash'"; 
     if($query_run=mysql_query($query)) 
     { 
     $query_num_rows=mysql_num_rows($query_run); 
     if($query_num_rows==0) 
     { 
      echo "error"; 
     } 
     else 
     { 
      echo "LOGGED IN"; 
     } 
     } 

    ?>