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

Php 为什么我收到HY093错误[PDO],php,mysql,pdo,Php,Mysql,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 ,

以下是我的功能:

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错误。当我用最基本的方法做的时候,它工作得非常完美

在我的数据库中:

  • 3DU id是一个整数,不能为空
  • 机器为varchar(30),可以为空
  • Started为datetime,不能为空
  • Grams是一个int,可以为null
  • 颜色为varchar(30),可以为空

就像变量一样,绑定也是区分大小写的

您的值
(:3d打印\u id

然后你在做什么

bindParam(":3dPrinting_id"
它们需要字母大小写匹配

bindParam(":3dprinting_id"

我会尽快接受这个问题。我甚至在其他问题中看到过这种类型的问题,但我无法解决。@cdm014我以前也犯过同样的错误,我相信很多其他人也犯过同样的错误,干杯