mysql create trigger error
<p>Been having issues creating trigger for enforcing foreign key check on MyISAM engine. Any suggestions? Please find error below.</p>

<blockquote>
  <p>SQLSTATE[42000]: Syntax error or access violation: 1064 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 'ERROR 1644 (45000): Custom ForeignKeyError
                      ELSEIF (SELECT CO' at line 8 (SQL:                 </p>
</blockquote>

<pre><code>CREATE TRIGGER insert_user_permission                 
BEFORE INSERT ON user_permissions 
            FOR EACH ROW
            BEGIN
                IF (SELECT COUNT(*) FROM users WHERE users.id=new.user_id)= 0 THEN                        
                    SIGNAL SQLSTATE '45000' 
                    SET MESSAGE_TEXT = 'Custom ForeignKeyError'
                    ERROR 1644 (45000): Custom ForeignKeyError
                ELSEIF (SELECT COUNT(*) FROM permissions WHERE permissions.id=new.permission_id)= 0 THEN
                    SIGNAL SQLSTATE '45000' 
                    SET MESSAGE_TEXT = 'Custom ForeignKeyError'
                    ERROR 1644 (45000): Custom ForeignKeyError
                END IF;
            END;)
</code></pre>