title: Creating functions in mysql doesnt work - Error 1064
body: <p>I tried this example via phpMyAdmin
  <a href="http://www.databasejournal.com/features/mysql/article.php/3569846/MySQL-Stored-Functions.htm" rel="nofollow">http://www.databasejournal.com/features/mysql/article.php/3569846/MySQL-Stored-Functions.htm</a></p>
  
  <pre><code>mysql&gt; DELIMITER |
  mysql&gt;
   CREATE FUNCTION WEIGHTED_AVERAGE (n1 INT, n2 INT, n3 INT, n4 INT)
    RETURNS INT
     DETERMINISTIC
      BEGIN
       DECLARE avg INT;
       SET avg = (n1+n2+n3*2+n4*4)/8;
       RETURN avg;
      END|
  </code></pre>
  
  <p>This worked</p>
  
  <pre><code>DELIMITER |
  </code></pre>
  
  <p>The next statement gave:</p>
  
  <pre><code>Error
  
  SQL query:
  
  CREATE FUNCTION WEIGHTED_AVERAGE(
  n1 INT,
  n2 INT,
  n3 INT,
  n4 INT
  ) RETURNS INT DETERMINISTIC BEGIN DECLARE avg INT;
  
  MySQL said: Documentation
  #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 '' at line 5 
  </code></pre>