Jump to content


Photo

MySQL trigger in PHP


  • Please log in to reply
1 reply to this topic

#1 B_Thax

B_Thax
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 30 July 2006 - 01:55 PM

I need to write a trigger with php but it do not seems to work. Here you got the code:

$sql_post_incrementor = "
DELIMITER $$
CREATE TRIGGER post_incrementor BEFORE INSERT ON 'ksys_content'
FOR EACH ROW
BEGIN
UPDATE ksys_usr SET posts = posts + 1 WHERE id = 'NEW.author';
END$$
DELIMITER ;";

$res_usr=mysql_query($sql_post_incrementor,$dbd);


I get that error:
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 'DELIMITER $$ CREATE TRIGGER post_incrementor BEFORE INSER

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 02 August 2006 - 02:50 PM

I assume you're using a trigger-friendly version of MySQL?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users