首页 > 解决方案 > getting this vague error in mysql You have an error in your SQL syntax; check... for the right syntax to use near ''

问题描述

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1

I am getting this error when I try to execute this query via phpmyadmin.

CREATE TRIGGER `msg_outbox_updated_by_before_insert` BEFORE INSERT ON `msg_outbox` FOR EACH ROW BEGIN SET new.updated_by=@userId; END;

This is the php code that I am using to generate and execute the query.

$dbconn->query("CREATE TRIGGER `" . $tableName . "_updated_by_before_insert` BEFORE INSERT ON `" . $tableName . "` FOR EACH ROW BEGIN SET new.updated_by=" . $newValue . "; END;");

This code runs but the trigger is not created.

Edit1: I just ran the above code on server and it worked, i.e. trigger is created. I just don't understand why is this not working on the local machine.

标签: phpmysqlmysqlitriggers

解决方案


推荐阅读