为什么我会收到 HY093 错误 [PDO]

Why am I receiving HY093 error [PDO]

这是我的函数:

function create($printing_id,$Machine,$Started,$Grams,$color) {
        //*
        $this->sql = "insert into `".$this->tableName."` (`3dprinting_id`,`Machine`,`Started`,`Grams`,`color`) values  ( :3dprinting_id , :Machine, :Started , :Grams , :color )";
        $this->stmt = $this->dbh->prepare($this->sql);
        $this->stmt->bindParam(":3dPrinting_id",$printing_id,PDO::PARAM_INT);
        $this->stmt->bindParam(":Machine",$Machine,PDO::PARAM_STR);
        $this->stmt->bindParam(":Started",$Started,PDO::PARAM_STR);
        $this->stmt->bindParam(":Grams",$Grams,PDO::PARAM_INT);
        $this->stmt->bindParam(":color",$color,PDO::PARAM_STR);
        $this->params = array();
        $this->params[":3dPrinting_id"] = $printing_id;
        $this->params[":Machine"] = $Machine;
        $this->params[":Started"] = $Started;
        $this->params[":Grams"] = $Grams;
        $this->params[":color"] = $color;
        return $this->stmt->execute();
        //*/
        /*
        $this->sql = "insert into `".$this->tableName."` (`3dprinting_id`,`Machine`,`Started`,`Grams`,`color`) values ($printing_id,'$Machine','$Started',$Grams,'$color')";
        return $this->dbh->exec($this->sql);
        //*/
    }

当我以最佳方式(未注释掉)执行此操作时,出现 HY093 错误。当我以最底层的方式进行时,它完美地工作。

在我的数据库中:

就像变量一样,绑定区分大小写。

你的价值观中有这个( :3dprinting_id

然后你在做

bindParam(":3dPrinting_id"

他们需要在字母大小写上匹配。

bindParam(":3dprinting_id"