Hi All

I'm trying to run the query below that I've taken from the MySQL documentation.

$sql = "delimiter |
                     CREATE TRIGGER testtrig AFTER INSERT ON test
                     FOR EACH ROW BEGIN
                           DELETE FROM testold WHERE id = NEW.id;
                     END;
                     |";
         $result = mysql_query($sql,$db);

The error I get is "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 arch AFTER INSERT ON xml_arch FOR EACH ROW BEGIN' at line 1"

The thing is, if I connect to the database using the Mysql Query Browser and run the same query it works. The tables I'm using exist, the username and password I'm using are the same to connect to the same local dataset. I can create tables but this trigger seems to be different'

Eventually I might be deploying to an environment where I can't get access to the remote database directly so I could do with getting this right

Many thanks
Tim

    Despite the delimiter statement, that is still multiple queries/sql statements to php and that is not supported by mysql_query

      7 days later

      Couldn't you send it as successive queries?

        Write a Reply...