简体   繁体   中英

I have a HY093 Error in this php/pdo code, but I can't find it

This is a piece of php code that I've written and I get a HY093 error, which according to what I've read is either a binding error or an error regarding the number of parameters passed or their quality, but I dont see anything wrong with my code.

Could it be that some of the variables is null when I'm passing it to the statements?

$sth = $connection->prepare(

                         "UPDATE `user_settings` 

                          SET 
                            user_show_money                 = :user_show_money, 
                            user_show_stats                 = :user_show_stats, 
                            user_accept_messages            = :user_accept_messages, 
                            user_interact_with_activities   = ':user_interact_with_activities' 

                            WHERE 

                            user_id = ':user_id'"

                        );  

$sth->execute(
                          array(

                                ':user_show_money'               => $user_show_money,
                                ':user_show_stats'               => $user_show_stats,
                                ':user_accept_messages'          => $user_accept_messages,
                                ':user_interact_with_activities' => $user_interact_with_activities,
                                ':user_id'                       => $user_id
                            ));



    $sth2 = $connection->prepare(

                        "UPDATE `users`

                         SET 
                             user_name      = :user_name,
                             user_avatar    = :avatar_path, 
                             user_sex       = :user_sex, 
                             user_password  = :user_password, 
                             user_quote     = :user_quote 

                             WHERE 

                             user_id         = :user_id"

                        );
    $sth2->execute(
                          array(

                                ':user_name'    => $user_name, 
                                ':avatar_path'  => $avatar_path, 
                                ':user_password'=> $user_password,
                                ':user_sex'     => $user_sex, 
                                ':user_quote'   => $user_quote,
                                ':user_id'      => $user_id 
                            ));

It's quite surprising you cannot find anything as this question has been asked many many many times already. And answers were listed to you while you typed your question.

For some reason you put your placeholders in quotes while you shouldn't.

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