title: Error Reporting? Import .sql file from PHP and show errors
body: <p>I am building a way of importing .SQL files into a MySQL database from PHP. This is used for executing batches of queries. The issue I am having is error reporting.</p>
  
  <pre><code>$command = "mysql -u $dbuser --password='$dbpassword' --host='$sqlhost' $dbname &lt; $file";
  exec($command, $output);
  </code></pre>
  
  <p>This is essentially how I am importing my .sql file into my database. The issue is that I have no way of knowing if any errors occurred within the PHP script executing this command. Successful imports are entirely indistinguishable from a failure.</p>
  
  <p>I have tried:</p>
  
  <ul>
  <li>Using PHP's sql error reporting functions.</li>
  <li>Adding the verbose argument to the command and examining the output. It simply returns the contents of the .sql file and that is all.</li>
  <li>Setting errors to a user variable within the .sql file and querying it from the PHP script.</li>
  </ul>
  
  <p>I hope I am not forced to write the errors into a temporary table. Is there a better way?</p>
  
  <p>UPDATE:
  If possible, it would be very preferable if I could determine WHAT errors occurred, not simply IF one occurred.</p>