Uncaught PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 in

Hello,

What is the error in the mysql code below, I couldn’t find it

I get this error: Fatal error: Uncaught PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn’t match value count at row 1 in

I get the following error when I change the value of the “selected” column in phpMyAdmin
popup error window
#1136 - Column count doesn't match value count at row 1

UPDATE `table_name` SET `selected` = '1' WHERE `table_name`.`id` = 1

Also when I upload the code from PhpMyAdmin I get the following error
Note: #1360 Trigger does not exist

MySQL code

DROP TABLE IF EXISTS `table_name`;
CREATE TABLE IF NOT EXISTS `table_name` (
  `id` int NOT NULL AUTO_INCREMENT,
  `column_1` varchar(128) NOT NULL,
  `column_2` varchar(128) NOT NULL,
  `column_3` varchar(128) NOT NULL,
  `column_4` varchar(128) NOT NULL,
  `column_5` varchar(128) NOT NULL,
  `selected` int NOT NULL DEFAULT '0',
  `column_6` varchar(100) DEFAULT NULL,
  `column_7` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `column_3` (`column_3`)
) ENGINE=MyISAM AUTO_INCREMENT=2;

INSERT INTO `table_name` VALUES(1, 'Lokal Anten', 'anten', 'fiyatı', 'para', '', 0, NULL, NULL);

DROP TRIGGER IF EXISTS `table_name_create`;
DELIMITER $$
CREATE TRIGGER `table_name_create` AFTER INSERT ON `table_name` FOR EACH ROW BEGIN
    insert into table_name_audit_trail(id, column_3, column_name, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_1', NEW.column_1, 'Eklendi', NEW.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_2', NEW.column_2, 'Eklendi', NEW.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_3', NEW.column_3, 'Eklendi', NEW.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_4', NEW.column_4, 'Eklendi', NEW.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_5', NEW.column_5, 'Eklendi', NEW.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'selected', NEW.selected, 'Eklendi', NEW.column_7);
END
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `table_name_update`;
DELIMITER $$
CREATE TRIGGER `table_name_update` AFTER UPDATE ON `table_name` FOR EACH ROW BEGIN
	IF OLD.column_1 <> new.column_1 THEN
        insert into table_name_audit_trail(id, column_3, column_name, old_value, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_1', OLD.column_1, NEW.column_1, 'Güncellendi', OLD.column_7, NEW.column_7);
    END IF;
	IF OLD.column_2 <> new.column_2 THEN
        insert into table_name_audit_trail(id, column_3, column_name, old_value, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_2', OLD.column_2, NEW.column_2, 'Güncellendi', OLD.column_7, NEW.column_7);
    END IF;
  IF OLD.column_3 <> new.column_3 THEN
        insert into table_name_audit_trail(id, column_3, column_name, old_value, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_3', OLD.column_3, NEW.column_3, 'Güncellendi', OLD.column_7, NEW.column_7);
    END IF;
	IF OLD.column_4 <> new.column_4 THEN
        insert into table_name_audit_trail(id, column_3, column_name, old_value, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_4', OLD.column_4, NEW.column_4, 'Güncellendi', OLD.column_7, NEW.column_7);
    END IF;
	IF OLD.column_5 <> new.column_5 THEN
        insert into table_name_audit_trail(id, column_3, column_name, old_value, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'column_5', OLD.column_5, NEW.column_5, 'Güncellendi', OLD.column_7, NEW.column_7);
    END IF;
	IF OLD.selected <> new.selected THEN
        insert into table_name_audit_trail(id, column_3, column_name, old_value, new_value, column_6, column_7) values(NEW.id, NEW.column_3, 'selected', OLD.selected, NEW.selected, 'Güncellendi', OLD.column_7, NEW.column_7);
    END IF;
END
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `table_name_delete`;
DELIMITER $$
CREATE TRIGGER `table_name_delete` AFTER DELETE ON `table_name` FOR EACH ROW BEGIN
    insert into table_name_audit_trail(id, column_3, column_name, old_value, column_6, column_7) values(OLD.id, OLD.column_3, 'column_1', OLD.column_1, 'Silindi', OLD.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, old_value, column_6, column_7) values(OLD.id, OLD.column_3, 'column_2', OLD.column_2, 'Silindi', OLD.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, old_value, column_6, column_7) values(OLD.id, OLD.column_3, 'column_3', OLD.column_3, 'Silindi', OLD.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, old_value, column_6, column_7) values(OLD.id, OLD.column_3, 'column_4', OLD.column_4, 'Silindi', OLD.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, old_value, column_6, column_7) values(OLD.id, OLD.column_3, 'column_5', OLD.column_5, 'Silindi', OLD.column_7);
    insert into table_name_audit_trail(id, column_3, column_name, old_value, column_6, column_7) values(OLD.id, OLD.column_3, 'selected', OLD.selected, 'Silindi', OLD.column_7);
END
$$
DELIMITER ;
COMMIT;

DROP TABLE IF EXISTS table_name_audit_trail;
CREATE TABLE IF NOT EXISTS `table_name_audit_trail` (
  `audit_id` int NOT NULL AUTO_INCREMENT,
  `id` int NOT NULL,
  `column_3` varchar(128) NOT NULL,
  `column_name` varchar(128) DEFAULT NULL,
  `old_value` varchar(128) DEFAULT NULL,
  `new_value` varchar(128) DEFAULT NULL,
  `column_6` varchar(128) DEFAULT NULL,
  `column_7` varchar(128) DEFAULT NULL,
  `done_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`audit_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;

I found the problem
Removing “OLD.column_7,” in values() in “table_name_update” trigger fixed the problem

Sponsor our Newsletter | Privacy Policy | Terms of Service