' SQLSTATE [HY093]:参数号无效:

时间:2017-10-10 22:33:04

标签: php

class User{
    private $db;
    public function __construct(){
        $this->db = new Database();
    }

    public function userRegistration($data){
            $name = $data['name'];
            $email = $data['email'];
            $username = $data['uid'];          
            $password = $data['pwd'];
            $confirm_pass = $data['pwd2'];
            $phn = $data['phn'];
            $dob = $data['dob'];
            $blood = $data['blood'];
            $religion = $data['rlgn'];
            $address = $data['addrs'];
            $country = $data['cntry'];

            $chk_email = $this->emailCheck($email);

            //Check empty field
            if($name == '' OR $username == '' OR $email == '' OR $password == '' OR $phn == ''){
                $msg = "<div class='alert alert-danger'>Must not be empty!!</div>";
                return $msg;
            }

            //Check password confirmation
             if(!$password == $confirm_pass){
                $msg = "<p>Password didn't match!</p>";
            }else{
                $password = md5($data['pwd']);
            }

            //Email validation
            if(filtet_var($email, FILTER_VALIDATE_EMAIL) === false) {
                $msg = "<p>Email address is not valid!!</p>";
                return $msg;
            }

            //Eamil check in database
            if($chk_email == true){
                $msg = "<p>Already exist!!</p>";
                return $msg;
            }

    }

    public function emailCheck(){
                $sql = "SELECT email from user_info WHERE email = :email";
                $query = $this->db->pdo->prepare($sql);
                $query->bindParam(" :email", $email);
                $query->execute();
                    if($query->rowCount() > 0){
                        return true;
                    } else{
                        return false;
                    }
    }
}    

我正在尝试使用提交的电子邮件检查数据库中的现有电子邮件,但上面给出的代码导致错误,就像 SQLSTATE [HY093]:无效的参数编号: WITH PDOException说参数不是定义。我不太熟悉PHP中的OOP方法。但是尝试将数据库与具有PDO功能的类连接起来。

这里有什么?

0 个答案:

没有答案