dongxiao3694 2013-12-30 02:28
浏览 49

还有一个 - PDO INSERT警告:PDOStatement :: execute() - SQLSTATE [HY093]:参数号无效:参数未在

I've checked my code over and over, looking for typos, and checked all the answers here and have not found an answer for this PDO insert warning. Here are my db columns:

 id (autoincrement), user_id, recipient, cc_email, reply, location, stationery, ink_color, fontchosen, message, attachment, messageDate.

Here is the output from my POST variables:

field is recipient and value is 123 
field is cc_email and value is  
field is reply and value is No 
field is location and value is heaven 
field is fontchosen and value is Arial 
field is attachment and value is 
field is message and value is abc 
field is stationery and value is images/stationery/patriotic.jpg

I calculate the user_id below this. The values that are blank above, can be NULL in the db. I check for default values (for instance ink_color) after the POST and add default values.

This is my sql printed to error_log:

sql is INSERT INTO messages (user_id,recipient, cc_email, reply, location,stationery, ink_color, fontchosen, message,attachment, messageDate ) VALUES( 4, :recipient, :cc_email, :reply, :location, :stationery, :ink_color, :fontchosen, :message, :attachment, NOW());

These are my params:

      $params = array(
        ':userid' => $userid,
    ':recipient' => $this->message_vars['recipient'],
        ':cc_email' => $this->message_vars['cc_email'],
        ':reply' => $this->message_vars['reply'],
    ':location' => $this->message_vars['location'],
    ':stationery' => $this->message_vars['stationery'],
        ':ink_color' => $this->message_vars['ink_color'],
        ':fontchosen' => $this->message_vars['fontchosen'],
        ':message' => $this->message_vars['message'],
    ':attachment' => $this->message_vars['attachment']
    );

There are 11 values for 11 columns, plus the id (auto increment). Can anyone see a problem with my PDO statement?

  • 写回答

1条回答 默认 最新

  • doutan3463 2013-12-30 02:35
    关注

    There is no :userid in your query, even though you bound it. That is the cause of the problem.

    This sort of thing would be easier to spot if you used a few newlines and lined your code up nicely…

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP