It's 9am, and I'm really tired, so I'm certain that everyone will see the error (at least, I'm hoping you'll gonna see it), but I've spend the last 45minutes on this, and don't see anything wrong
So I'm trying to insert a row in a mysql db with pdo (god dammit, I did it billions of times)
$sthInsert = $dbh->prepare('insert into Chambre (id_Departement, nom_Chambre, prix_Chambre, actif_Chambre, plan_Chambre, position_Chambre) values(:idDepartement, :nom, :prix, :actif, :plan, :position)');
$sthInsert->execute(array(
':idDepartement' => $lstAncienDepartement[$result['knpdepartement']],
':nom' => $result['title'],
':prix' => $result['prix_mensuel'] * 100,
':actif' => true,
':plan' => null,
':position' => null
));
When I try to execute this, I get this error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
But, I count it, I have 6 variable in my query and 6 in my executed function...
This is the values I send
':idDepartement' => string '4' (length=1) ':nom' => string '103' (length=3) ':prix' => int 0 ':actif' => boolean true ':plan' => null ':position' => null
And this is the create table statement
CREATE TABLE `Chambre` ( `id_Chambre` int(11) NOT NULL AUTO_INCREMENT, `id_Departement` int(11) NOT NULL, `nom_Chambre` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `prix_Chambre` int(11) NOT NULL, `actif_Chambre` tinyint(1) NOT NULL, `plan_Chambre` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, `position_Chambre` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id_Chambre`), KEY `id_Departement` (`id_Departement`), CONSTRAINT `Chambre_ibfk_1` FOREIGN KEY (`id_Departement`) REFERENCES `Departement` (`id_Departement`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Thank you
---------- Post added at 09:46 AM ---------- Previous post was at 09:21 AM ----------
I knew it's was stupid...
My code was working, but inside a while, and later I changed the value of $sthInsert


Sign In
Create Account


Back to top









