I’m making good progress with my conversion but have run into a problem with one script. I have a couple of other similar scrips that work fine, but this one comes up with a fatal error. I’m not sure how much of the code I need to share…
$q = 'UPDATE hall SET name=:name, phone=:phone, address=:address, rent=:rent, size=:size, manager_id=:manager_id WHERE hall_id = :$hall_id';
$data = ['hall_id' => $hall_id, 'name' => $name, 'phone' => $phone, 'address' => $address, 'rent' => $rent, 'size' => $size, 'manager_id' => $manager_id];
$stmt = $pdo->prepare($q);
$stmt->execute($data);
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 25 column index out of range in C:.…\edit_hall.php:26 Stack trace: #0 C:.…\edit_hall.php(26): PDOStatement->execute(Array) #1 {main} thrown in C:.…\edit_hall.php on line 26
Line 26 is the execute()
This is the schema:
CREATE TABLE IF NOT EXISTS "hall" (
"hall_id" INTEGER,
"name" TEXT,
"phone" TEXT,
"address" TEXT,
"rent" INTEGER,
"size" TEXT,
"manager_id" INTEGER,
PRIMARY KEY("hall_id")
);
and this is the test data:
INSERT INTO "hall" ("hall_id","name","phone","address","rent","size","manager_id") VALUES (1,'Gec Community Hall','018xxxxxx','GEC circle',400,'1200',8);
INSERT INTO "hall" ("hall_id","name","phone","address","rent","size","manager_id") VALUES (2,'agrabad Community','-','ctg',1200,'1200',7);
INSERT INTO "hall" ("hall_id","name","phone","address","rent","size","manager_id") VALUES (4,'CDA Community','-','Halishahar.ctg',1200,'1200',7);
INSERT INTO "hall" ("hall_id","name","phone","address","rent","size","manager_id") VALUES (11,'Pavillion','none','Recreation field',10,'200',6);
INSERT INTO "hall" ("hall_id","name","phone","address","rent","size","manager_id") VALUES (12,'Village Hall','none','Church Lane',10,'100',8);