选择特定的行php和mysql

时间:2014-05-21 06:57:35

标签: php mysql database

我知道它听起来像是重复但实际上我没有找到问题的答案。

我正在制作表格以获取密码的具体细节 这是表格

<form method="post" name="lostpass" action="forgotpass.php">
                        <ul>
                        <li>Admin Name:<input name="admin" type="text"></li>
                        <li> E.mail: <input name="email" type="text"><br></li>  
                        </ul>
                        <input type="submit" name="get" value="get infos">
                        <input type="reset" name="reset" value="Reset">
                    </form>

所以我得到的这些数据我可以得到丢失的密码

这是php代码

 <?php
    $con=mysqli_connect("rock","mido","1234","fyp");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

     $result = mysqli_query($con,"SELECT password FROM admin WHERE email = 'email', Admin = 'admin' ");
      while($row = mysqli_fetch_array($result))

    echo  $row['password'];

    mysqli_close($con);
    ?>

它给我这个错误(mysql_fetch_array()期望参数1是mysqli_result)。

thanx求助

1 个答案:

答案 0 :(得分:1)

替换此代码:

$result = mysqli_query($con,"SELECT password FROM admin WHERE email = 'email', Admin = 'admin' ");

 $result = mysqli_query($con,"SELECT password FROM admin WHERE email = '$_POST[email]' AND Admin = '$_POST[admin]'");

感谢。