I am trying to use a simple MySQL insert query with the parameters in array form. It keeps telling me the number of parameters are wrong :
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
Here is my code
try
{
$bdd = new PDO('mysql:host=localhost;dbname=looktallshoes;charset=utf8',
'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$req = $bdd -> prepare("INSERT INTO products (product-title, product-
category, product-source, source-link, product-price, price-before-discount,
product-source-price, height-increase, admin-product-short-description,
admin-product-long-description, large-main-name, square-main-name, other-
photo-1-name, other-photo-2-name, other-photo-3-name, other-photo-4-name)
VALUES(:product-title, :product-category, :product-source, :source-link,
:product-price, :price-before-discount, :product-source-price, :height-
increase, :admin-product-short-description, :admin-product-long-description,
:large-main-name, :square-main-name, :other-photo-1-name, :other-photo-2-
name, :other-photo-3-name, :other-photo-4-name)");
$req->execute(array(
'product-title'=>$_POST['product-title'],
'product-category'=>$_POST['product-category'],
'product-source'=>$_POST['product-source'],
'source-link'=>$_POST['source-link'],
'product-price'=>$_POST['product-price'],
'price-before-discount'=>$_POST['price-before-discount'],
'product-source-price'=>$_POST['product-source-price'],
'height-increase'=>$_POST['height-increase'],
'admin-product-short-description'=>$_POST['admin-product-short-
description'],
'admin-product-long-description'=>$_POST['admin-product-long-
description'],
'large-main-name'=>$_POST['large-main-name'],
'square-main-name'=>$_POST['square-main-name'],
'other-photo-1-name'=>$_POST['other-photo-1-name'],
'other-photo-2-name'=>$_POST['other-photo-2-name'],
'other-photo-3-name'=>$_POST['other-photo-3-name'],
'other-photo-4-name'=>$_POST['other-photo-4-name'],
));