PHP / MySQL查询没有执行

时间:2017-05-19 00:01:51

标签: php mysql

标题显示我的PHP / MySQL查询没有执行

有些人可以看看你做错了吗?

  $name = ((isset($_POST['name']))?sanitize($_POST['name']):'');
  $email = ((isset($_POST['email']))?sanitize($_POST['email']):'');
  $password = ((isset($_POST['password']))?sanitize($_POST['password']):'');
  $confirm = ((isset($_POST['confirm']))?sanitize($_POST['confirm']):'');
  $errors = array();
  if($_POST){
    $emailQuery =$db->query("SELECT  FROM users1 WHERE email = '$email'");
    $emailCount = mysqli_num_row($emailQuery);

        if($emailCount != 0){
          $errors[] = 'That email already exists in our database.';
        }

1 个答案:

答案 0 :(得分:1)

代码中的两个问题

  1. 您的查询中缺少*
  2. mysqli_num_row应该是mysqli_num_rows
  3. 这是正确的代码

      $name = ((isset($_POST['name']))?sanitize($_POST['name']):'');
      $email = ((isset($_POST['email']))?sanitize($_POST['email']):'');
      $password = ((isset($_POST['password']))?sanitize($_POST['password']):'');
      $confirm = ((isset($_POST['confirm']))?sanitize($_POST['confirm']):'');
      $errors = array();
      if($_POST){
        $emailQuery =$db->query("SELECT * FROM users1 WHERE email = '$email'");
        $emailCount = mysqli_num_rows($emailQuery);
    
            if($emailCount != 0){
              $errors[] = 'That email already exists in our database.';
            }