mysql_select_db()期望参数2是资源,给定PHP验证的对象

时间:2015-12-18 07:09:36

标签: php mysql mysqli

我正在尝试使用PHP验证用户登录,但是我收到以下错误

  

警告:mysql_select_db()期望参数2是资源,对象   在第18行的C:\ xampp \ htdocs \ db \ sign_in_connect.php中给出

     

警告:mysql_fetch_array()期望参数1是资源,   第22行的C:\ xampp \ htdocs \ db \ sign_in_connect.php中给出的布尔值   抱歉,您的凭据无效,请重试。

这是我的PHP代码

<?php
try{
  $db = mysqli_connect ('localhost', 'root', '', 'car_rental') or die ("SQL is Off");

}
catch (Exception $e){
  echo "SQL is Off";
  exit;

}
echo "success"; 

$email = $_POST["email"];
$pass = $_POST["pass"];



mysql_select_db("car_rental",$db);

$result = mysql_query("SELECT email, users FROM users WHERE email = $email");

$row = mysql_fetch_array($result);

if($row["email"]==$email && $row["pass"]==$pass)
    echo"You are a validated user.";
else
    echo"Sorry, your credentials are not valid, Please try again.";


?>

1 个答案:

答案 0 :(得分:0)

用此替换您的代码。

 AdView.setAdListener(new AdListener() {
     // Implement AdListener
 });