简体   繁体   English

我在此php / pdo代码中遇到了HY093错误,但找不到

[英]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. 这是我编写的一段php代码,但出现了HY093错误,根据我所读的内容,这可能是绑定错误,也可能是有关传递的参数数量或其质量的错误,但我什么也看不到我的代码有误。

Could it be that some of the variables is null when I'm passing it to the statements? 当我将其传递给语句时,某些变量可能为null吗?

$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. 出于某些原因,您应该将占位符放在引号中,而不应这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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