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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记