dsfsw1233 2013-10-24 20:21
浏览 43
已采纳

PDO:参数号无效:未定义参数。 但我有所有的领域?

I'm having trouble with this insert statement. It is inside an if statement and used after a user successfully uploads and image.

                $contenido = $filename;
                $db = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
                $data = $db->prepare("INSERT INTO publicaciones (autorID, autorNombre, nombre, claseDeContenido, contenido, palabras, etiquetas, fecha) VALUES (:autorID, :autorNombre, :nombre, :claseDeContenido, :contenido, :palabras, :etiquetas, :fecha)");
                $data->execute(array( ':autorID,' =>$autorID,
                            ':autorNombre' =>$autorNombre,
                            ':nombre' => $nombre,
                            ':claseDeContenido' => $claseDeContenido,
                            ':contenido' => $contenido,
                            ':palabras' =>$palabras,
                            ':etiquetas' => $etiquetas,
                            ':fecha' => $fecha));

The error is

PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in .... on line 215

But there is no change of that variable name within the script, there are eight parameters to insert and I am sending 8. I have checked and $fecha, which is on line 215, is definitely being sent.

What could it be?

None of this function is run without all fields being present in their respective variables.

if($autorID !== '' || $autorNombre !== '' || $nombre !== '' || $claseDeContenido !== '' || $contenido !== '' || $palabras !== '' || $etiquetas !== '' || $fecha !== '')

NOTE: The image is uploading succesfully

  • 写回答

3条回答 默认 最新

  • dsgsdg206050 2013-10-24 20:25
    关注

    You have a superfluous comma in the reference to :autorID:

                    $data->execute(array( ':autorID,' =>$autorID,
    //                                             ^--- remove this comma
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示