SQLSTATE [HY093]:参数号无效:绑定变量数与令牌错误数不匹配

时间:2016-06-02 01:22:08

标签: php mysql sql

我的两个页面上出现此错误,我无法理解原因。我已经重写了代码并对其进行了三重检查,但我无法找到问题所在。

第一个是:

vpc_subnet_id: subnet-29e63245

第二个是:

 public function academics ($id,$problem_solving ,  $math_understanding,      $cs_understanding ,   $math_useful ,  $cs_useful, $math_ava,  $cs_ava,    $assigment_start,   $assigment_submit,  $travel_time,   $stress,$assigment_when,    $full_part,     $pair_programming,  $attending_class,   $attending_labs,$attending_tutorials,   $extra_reading, $p_progamming,  $q_cs,  $q_maths,   $procrastinating_assigments,    $procrastinating_studying){
    try{
        $stmt = $this->db->prepare("UPDATE student_data SET problem_solving=:problemS, math_understanding=:math_U, cs_understanding=: cs_u, math_useful =:m, cs_useful=:cs_u, math_ava=:ma, cs_ava=:ca, assigment_start=:ass_st, assigment_submit=:assigment_submit, travel_time =:travel_time, stress=: stress, assigment_when =:assigment_when, full_part =:full_part, pair_programming=: pair_programming,   attending_class=: attending_class, attending_labs=: attending_labs, attending_tutorials =:attending_tutorials, extra_reading =:extra_reading, p_progamming=: p_progamming,  q_cs=: q_cs,    q_maths=: q_maths, procrastinating_assigments=:procrastinating_assigments, procrastinating_studying=:procrastinating_studying WHERE user_id=:uid");
        $stmt->bindparam(":uid", $id);
        $stmt->bindparam(":problemS",$problem_solving );
        $stmt->bindparam(":math_U",$math_understanding);
        $stmt->bindparam(":cs_u",$cs_understanding );
        $stmt->bindparam(":m",$math_useful );
        $stmt->bindparam(":cs_u",$cs_useful);
        $stmt->bindparam(":ma",$math_ava);
        $stmt->bindparam(":ca",$cs_ava);
        $stmt->bindparam(":ass_st",$assigment_start);
        $stmt->bindparam(":assigment_submit",$assigment_submit);
        $stmt->bindparam(":travel_time",$travel_time);
        $stmt->bindparam(":stress",$stress);
        $stmt->bindparam(":assigment_when",$assigment_when);
        $stmt->bindparam(":full_part",$full_part    );
        $stmt->bindparam(":pair_programming",$pair_programming);
        $stmt->bindparam(":attending_class",$attending_class);
        $stmt->bindparam(":attending_labs",$attending_labs);
        $stmt->bindparam(":attending_tutorials",$attending_tutorials);
        $stmt->bindparam(":extra_reading",$extra_reading);
        $stmt->bindparam(":p_progamming",$p_progamming);
        $stmt->bindparam(":q_cs",$q_cs);
        $stmt->bindparam(":q_maths",$q_maths);
        $stmt->bindparam(":procrastinating_assigments",$procrastinating_assigments);
        $stmt->bindparam(":procrastinating_studying",$procrastinating_studying);
        $stmt->execute(); 
    } catch(PDOException $e)
    {
        echo $e->getMessage();
    }  
}

1 个答案:

答案 0 :(得分:4)

好的,这对于评论来说太长了(没有双关语意图在那个"长"顺便说一句)。

如果那些错别字(我希望他们不是),那么你有很多在冒号后面有空格的绑定。

您需要删除它们的空格,并将MySQL保留字包裹在LONG的刻度中,或者将其重命名为保留字以外的其他内容。

SET `long`=:long, ...

参考:

<强>脚注:

TBH:我没有计算你所有的约束力,所以如果我错过了什么,你就需要重复一遍,确保它们都匹配。

修改

  

&#34;我不知道php的空间数,认为它忽略了它们就像C / C ++一样,现在可以使用了。谢谢大家!! - bandos&#34;

  • 这不是C / C ++,它的PHP和空格确实用这种语言计算。