Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:05:16+00:00 2026-06-06T13:05:16+00:00

I am trying to automate my trigger process so that I don’t have to

  • 0

I am trying to automate my trigger process so that I don’t have to manually create triggers for every table I want to use. Unfortunately, I get an error back saying there is a syntax error.

Here is my code

$updateTrigger = "DROP TRIGGER IF EXISTS {$table}Update
    CREATE TRIGGER {$table}Update AFTER UPDATE ON $table
    FOR EACH ROW
    BEGIN
       DECLARE N DATETIME;
       SET N = now();
       INSERT INTO StagesHistory (Stage, StageID, Date, Action)
       VALUES ('$table', NEW.ID, N, ?);
    END";

$ut = $dbh->prepare($updateTrigger);
$ut->execute(array($update));
$error = $ut->errorInfo();

Evaluating $error returns this error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘CREATE TRIGGER TranslationUpdate AFTER UPDATE ON Translation
FOR EACH R’ at line 2

I can’t figure out what error it’s talking about. What’s the problem, and how do I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:05:18+00:00Added an answer on June 6, 2026 at 1:05 pm

    DROP TRIGGER ... and CREATE TRIGGER ... are two separate statements. You need to at least separate them with a ;, possibly execute them in separate queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to automate the build process for engineering group. As part of that
I am trying to create a trigger that will update a GEOMETRY column based
I'm trying to automate a little tedious process I have to go through while
I'm trying to automate data merge process. Here's what I have: First of all
I am trying to automate the install process for OpenMRS developers http://wiki.openmrs.org/display/docs/Step+by+Step+Installation+for+Developers I have
I'm trying to automate building process of xcode project. The problem is that I
I am trying to automate data extraction from a website and I really don't
Am trying to automate the process of uploading an artifact generated by Maven into
I'm trying to automate a web process where I need to click a button
Im trying to automate video conversion with powershell and ffmpeg tool. Ffmpeg have detailed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.