title: MySQL Error by creating Stored Procedure
body: <p>I want to make a Stored Procedure that handles an order from our site. The problem is that when I run the script there is a MySQL syntax error. I'm very new with MySQL Stored Procedures. Can someone look at my code?</p>
  
  <pre><code>USE postbrood;
  DELIMITER //
  CREATE PROCEDURE MaakBestelling(IN KlantIDParam INT, IN ProductIDArray VARCHAR(255), IN AantalArray VARCHAR(255))
  
  BEGIN
  DECLARE BestelID INT DEFAULT 0;
  DECLARE ArrayLenght INT DEFAULT 0;
  DECLARE Counter INT DEFAULT 0;
  
  
  
  SET ArrayLenght = LENGTH(ProductIDArray) - LENGTH(REPLACE(ProductIDArray, ',', '')) + 1;
  
  
  INSERT INTO bestelling(klantID) VALUES (KlantIDParam);
  SET BestelID = LAST_INSERT_ID();
  
  WHILE Counter &lt; ArrayLenght DO
  INSERT INTO bestelregel VALUES (SUBSTRING_INDEX(ProductIDArray,',',Counter),BestelID,SUBSTRING_INDEX(AantalArray,',',Counter));
  SET Counter = Counter + 1;
  END WHILE;
  END//
  DELIMITER ;
  </code></pre>
  
  <p>Thanks in advance!</p>