title: mysql query works in phpmyadmin but errors in php
body: <p>The following query works fine in phpmyadmin:</p>
  
  <pre><code>SELECT CONCAT(
    'SELECT `formSubmissionDetails`.formSubmissionId', GROUP_CONCAT('
       ,    `t_', REPLACE(fieldName, '`', '``'), '`.fieldValue
           AS `', REPLACE(fieldName, '`', '``'), '`'
       SEPARATOR ''),
   ' FROM `formSubmissionDetails` ', GROUP_CONCAT('
       LEFT JOIN `formSubmissionDetails`   AS `t_', REPLACE(fieldName, '`', '``'), '`
              ON `formSubmissionDetails`.formSubmissionId = `t_', REPLACE(fieldName, '`', '``'), '`.formSubmissionId
             AND `t_', REPLACE(fieldName, '`', '``'), '`.fieldName = ', QUOTE(fieldName)
       SEPARATOR ''),
   ' GROUP BY `formSubmissionDetails`.formSubmissionId'
  ) INTO @qry FROM (SELECT DISTINCT fieldName FROM `formSubmissionDetails`) t;
  
  PREPARE stmt FROM @qry;
  EXECUTE stmt;
  </code></pre>
  
  <p>I get the following error from mysqli when attempting to run it via php:</p>
  
  <blockquote>
    <p>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 'PREPARE stmt FROM @qry; EXECUTE stmt' at line 9</p>
  </blockquote>
  
  <p>Here is a working sqlfiddle: <a href="http://sqlfiddle.com/#!2/803ee/1" rel="nofollow">http://sqlfiddle.com/#!2/803ee/1</a></p>
  
  <p>I'm just really stumped.</p>