gpt4 book ai didi

php - PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: 无效

转载 作者:行者123 更新时间:2023-11-30 00:36:51 27 4
gpt4 key购买 nike

PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: 无效的参数数量:绑定(bind)变量的数量与标记数量不匹配 我收到此错误 为什么?列名称正确。

enter image description here

$baslik         = $_POST["makale_basligi"];
$icerik = trim($_POST["makale_icerigi"]);
$meta_desc = $_POST["makale_meta_description"];
$id = $_POST["makale_id"];
$kategori = $_POST["makale_kategorisi"];
$makale_link = convertTextToLinkFormat($baslik);

$update_makale = $db->prepare("UPDATE makale SET "
. "makale_kategorisi = :kategori,"
. "makale_link_baslik = :link,"
. "makale_baslik = :baslik, "
. "makale_icerik = :icerik, "
. "makale_meta_description = :desc WHERE makale_id = '".$id."' ");
$update_makale->execute(array(':kategori'=>$kategori,':link'=>$makale_link ,':baslik' =>$baslik,':icerik' =>$icerik,':desc' =>$meta_desc));

最佳答案

我认为对 $id 值进行硬编码并将其与 PDO 参数混合不是一个好主意。它很容易出错,并且 Id 在表中被定义为 int,所以为什么要引用它?

将其与其他参数一起放入数组中:

$update_makale  = $db->prepare("UPDATE makale SET "
. "makale_kategorisi = :kategori,"
. "makale_link_baslik = :link,"
. "makale_baslik = :baslik, "
. "makale_icerik = :icerik, "
. "makale_meta_description = :desc WHERE makale_id = :id");

$update_makale->execute(array(
':kategori' => $kategori,
':link' => $makale_link,
':baslik' => $baslik,
':icerik' => $icerik,
':desc' => $meta_desc,
':id' => $id
));

关于php - PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22104592/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com