I am using following PHP code for trigger creation but always get error, please help me to resolve i
Posted
by Parth
on Stack Overflow
See other posts from Stack Overflow
or by Parth
Published on 2010-03-30T11:22:29Z
Indexed on
2010/03/30
11:43 UTC
Read the original article
Hit count: 407
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...
© Stack Overflow or respective owner