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 704779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:58:47+00:00 2026-05-14T03:58:47+00:00

I am using following PHP code for trigger creation but always get error, please

  • 0

I am using following PHP code for trigger creation but always get error, please help me to resolve it.

$link = mysql_connect('localhost','root','rainserver');
    mysql_select_db('information_schema');
                echo $trgquery = "DELIMITER $$ DROP TRIGGER `update_data` $$ CREATE TRIGGER `update_data` AFTER UPDATE on `jos_menu` FOR EACH ROW BEGIN
IF (NEW.menutype != OLD.menutype) THEN
INSERT INTO jos_menuaudit set menuid=OLD.id, oldvalue = OLD.menutype, newvalue = NEW.menutype, field = 'menutype';
END IF;
IF (NEW.name != OLD.name) THEN
INSERT INTO jos_menuaudit set menuid=OLD.id, oldvalue = OLD.name,

newvalue = NEW.name, field = 'name';
END IF;
IF (NEW.alias != OLD.alias) THEN
INSERT INTO jos_menuaudit set menuid=OLD.id, oldvalue = OLD.alias,

newvalue = NEW.alias, field = 'alias';
END IF;
END$$ DELIMITER ;";
                echo "<br>";
        //$trig = mysqli_query($link,$trgquery) or die("Error Exist".mysqli_error($link));
         $trig = mysql_query($trgquery) or die("Error Exist".mysql_error());

I get the error as:

Error ExistYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$$ DROP TRIGGER `update_data` $$ CREATE TRIGGER `update_data` AFTER UPDATE on `j' at line 1

PLease help me to create my trigger…

  • 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-05-14T03:58:48+00:00Added an answer on May 14, 2026 at 3:58 am

    The error tells you exactly what’s wrong. DELIMITER $$ DROP ... isn’t a valid statement. Part of the reason for this is delimiter is a MySQL command, not a statement. Another reason is the “$$” in “DELIMITER $$” is part of the command and thus doesn’t terminate the command. You still need to include the old delimiter.

    According to the documentation, mysql_query doesn’t support multiple statements, so you’ll have to issue separate queries for each one. Better yet, switch to the newer mysqli driver, whose multi_query function works for multiple statements in a single query. mysqli also supports prepared statements, which doesn’t matter so much in your example, but does in most other situations. PDO is even newer and also supports prepared statements, and I believe the PDO MySQL driver supports multi-queries.

    As an alternative to triggers, row-based binary logging will record changes made to tables in a database.

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

Sidebar

Related Questions

I'm currently using the following PHP code: // Get all subordinates $subords = array();
I'm using the following code to get response from a requested page using php
I am using the following PHP code... $settings[] = get_app_settings(); echo $settings['weight_unit']; but its
I'm using the following PHP code to return a json string: $itemURL = 'http://***.***.***/search?tag=Football&affiliate_id=&max_results=3';
So I'm using the following php code to set variables that are received from
OK, i was using following code to reverse a date to use in php
I am using the following code to generate excel from sql through php.this is
I'm using the following line of code to run my php file that I
I am using the following code: <?php $pattern = /(?<item>.*)\:(?<value>.*)(\{(?<flag>.*)_(?<level>.*)\})/i; $subject = item:value{L_300}; preg_match($pattern,
I am using the following code : <?php $start_time = microtime(true); for($i=1;$i <= 999999;

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.