title: mysqldump via PHP
body: <p>I have a PHP script that gets passed the MySQL connection details of a remote server and I want it to execute a <code>mysqldump</code> command. To do this I'm using the php <code>exec()</code> function:</p>
  
  <pre><code>&lt;?php
  exec("/usr/bin/mysqldump -u mysql-user -h 123.145.167.189 -pmysql-pass database_name &gt; /path-to-export/file.sql", $output);
  ?&gt;
  </code></pre>
  
  <p>When the right login details are passed to it, it'll work absolutely fine.
  However, I'm having trouble checking <em>if</em> it executes as expected and if it doesn't finding out why not.
  The <code>$output</code> array returns as empty, whereas if I run the command directly on the command line a message is printed out telling me the login failed. I want to capture such error messages and display them. Any ideas on how to do that?</p>