没有错误,var dump看起来是正确的,不会插入


no errors, var dump looks right and wont insert

我想知道是否有人知道这个错误的含义

PDOStatement::execute():SQLSTATE[HY093]:无效的参数编号:绑定变量的数量与标记的数量不匹配Database.php在线95

第83-97行数据库.php

    ksort($data);
    //$fieldNames = implode(', ', array_keys($data));   /// to be tested
    $fieldNames = implode('`, `', array_keys($data));
    $fieldValues = ':' . implode(', :', array_keys($data));
    $sth = $WIdb->prepare("INSERT INTO $table (`$fieldNames`) VALUES ($fieldValues)");
    foreach ($data as $key => $value) {
        $sth->bindValue(":$key", $value);
    }
    $sth->execute();
    $sth->closeCursor();

我的数据库插件

$this->WIdb->insert("WI_Members", array(
            ":email"             => $user['email'],
            ":username"          => strip_tags($user['username']),
            ":password"          => $this->hashPassword($user['password']),
            ":full_name"       => strip_tags($user['full_name']),
            ":birthday"          => $full_birthday,
            ":gender"            => $user['gender'],
            ":country"           => $user['country'],
            ":confirmed"         => $confirmed,
            ":confirmation_key"  => $key,
            ":register_date"     => date("Y-m-d")     
        ));  

尝试重新编码我的网站,停止sql注入,它通过了所有验证,

我做了VAR转储

["email"]=>
  string(21) "test@googlemail.com"
  ["username"]=>
  string(12) "warner"
  ["full_name"]=>
  string(6) "Jules "
  ["password"]=>
  string(128) "db0773097ac0e01005f698bc50488524f3bea68b545ad35aa8ac73ce5c3b447b82aebcab45763a650a9195caf11cf9e7fd3f6f67265f371702ef07128bb65cdf"
  ["confirm_password"]=>
  string(128) "db0773097ac0e01005f698bc50488524f3bea68b545ad35aa8ac73ce5c3b447b82aebcab45763a650a9195caf11cf9e7fd3f6f67265f371702ef07128bb65cdf"
  ["gender"]=>
  string(1) "m"
  ["birthmonth"]=>
  string(2) "02"
  ["birthday"]=>
  string(2) "22"
  ["birthyear"]=>
  string(4) "1980"
  ["country"]=>
  string(14) "United Kingdom"
  ["bot_sum"]=>
  string(2) "10"

我看了几个论坛,我尝试了很多比特,似乎都不起作用,我已经醒了24小时试图解决这个问题,所以我想我会在这里尝试新鲜的可能会帮助lol

感谢大家抽出时间

您的错误意味着查询中的项数与值数组中的项数来不匹配。

您正在声明一定数量的参数,但具有其值的数组的长度不同。

检查它们是否匹配并进行相应的修复以解决问题。