I'm trying to edit an INSERT query using bindParam().
Here is my code.
public function addProduct()
{
$query = "INSTERT INTO producten (name, model, price, image, description)
VALUES (:name, :model, :price, :image, :description)";
$stmt = $this->dbh->prepare($query);
$stmt->bindParam(":name", $_POST['name']);
$stmt->bindParam(":model", $_POST['model']);
$stmt->bindParam(":price", $_POST['price']);
$stmt->bindParam(":image", $_FILES['file']['name']);
$stmt->bindParam(":description", $_POST['description']);
print_r($stmt);
}
$dbh object is created in the contruct function of the class;
public function __construct()
{
$user = "root";
$pass = "";
$this->dbh = new \PDO('mysql:host=localhost;dbname=projectname', $user, $pass);
}
The $stmt->bindParam() returns true when tested but does not replace the given parameters.
Does anyone know what i'm doing wrong?