【问题标题】:Unexpected end of file in PHP code [closed]PHP代码中的文件意外结束[关闭]
【发布时间】:2014-02-22 01:10:52
【问题描述】:

谁能理解我为什么会收到以下错误:

语法错误,第 70 行 D:\wamp\www\main\index.php 中的文件意外结束

如果有人能推荐一个更适合 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>

【问题讨论】:

  • 这篇文章就像一个特制的投票磁铁。
  • 您可能缺少;})。仔细检查您的代码。
  • 不知是否使用用户名' OR 1=1--登录?
  • @NickR:你不是说' OR 1=1 -- 吗? :-)
  • @RocketHazmat 是的,可能:)

标签: php html


【解决方案1】:

你需要关闭两个大括号..!

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

?>

【讨论】:

    【解决方案2】:
    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";
          }
          }
    
         ?>  
    

    【讨论】:

      【解决方案3】:

      if/then 缺少两个右花括号 if($query_run=mysql_query($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";
              }
          }
      }
      

      我感觉这个问题很快就会结束……祝你好运

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-07-27
        • 1970-01-01
        • 2012-06-10
        • 2012-07-14
        相关资源
        最近更新 更多