here is my function:
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);
//*/
}
When I do it the top way (not commented out) I get an HY093 error. When I do it the bottom way it works perfectly.
In my database:
Just like variables, binds are case-sensitive.
You have this in your values ( :3dprinting_id
and then you're doing
bindParam(":3dPrinting_id"
They need to match in letter-case.
bindParam(":3dprinting_id"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With