php - 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.
解决方案
推荐阅读
- java - 我可以在一个活动中设置两个内容视图吗?
- javascript - How to use multiple quotes inside php echo
- google-maps - Google API - credit endpoint
- scala - 什么是 sbt 存储库
- protractor - Unable to debug angular e2e tests with Protractor in VS-Code
- laravel - BadMethodCallException Call to undefined method App\Student::generateToken()
- sql-server - How to Fake tables from other database in tsqlt?
- php - How to take screen shot of a web page in PHP and show it in model popup and submit it into database
- django - 添加包时的 Python 诗歌 [EnvCommandError]
- php - How to redirect multiple files in same directory using nginx?