简体   繁体   中英

Error in PHP PDO Prepared Statement

try 
{

    $stmt = $conn->prepare(" Update site_users SET users_first_name = :users_first_name, users_last_name = users_last_name
    ,users_email_verified = :users_email_verified , users_password = :users_password, users_dob_day = :users_dob_day, users_dob_month = :users_dob_month
    ,users_dob_year = :users_dob_year, users_password_1 = :users_password_1, users_registration_time= :users_registration_time 
    WHERE users_email = :users_email");

    $stmt->bindParam(':users_first_name', $_POST["firstname"] , PDO::PARAM_STR);
    $stmt->bindParam(':users_last_name', $_POST["lastname"]  , PDO::PARAM_STR);
    $stmt->bindParam(':users_email', $_POST["email"] , PDO::PARAM_STR);
    $stmt->bindParam(':users_password', $hashed_password , PDO::PARAM_STR);
    $stmt->bindParam(':users_password_1', $_POST["password"] , PDO::PARAM_STR);
    $stmt->bindParam(':users_email_verified', $users_email_verified , PDO::PARAM_STR);
    $stmt->bindParam(':users_dob_day', $_POST["day"], PDO::PARAM_STR);
    $stmt->bindParam(':users_dob_month', $_POST["month"], PDO::PARAM_STR);
    $stmt->bindParam(':users_dob_year', $_POST["year"], PDO::PARAM_STR);
    $stmt->bindParam(':users_registration_time',$date, PDO::PARAM_STR);

    $stmt->execute();

}

catch(PDOException $e) 
{
        echo "Error: " . $e->getMessage();
}

This is the error, the code echo

Error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Where is the problem in this code?

i think you are missing the : in your users_last_name = users_last_name query

probably it has to be users_last_name = :users_last_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM