title: php exec() - mysqldump creates an empty file
body: <p>I want to create a backup from a database, but I get only a blank file.</p>
  
  <pre><code>include('config.php');
  
  $command = "mysqldump --opt -h ".$_host." -u ".$_user." -p ".$_pass." ".$_db." &gt; test.sql";
  exec($command);
  
  echo "&lt;br /&gt;".$command;
  </code></pre>
  
  <p>test.sql is created where the .php file is located.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Note! I'm using XAMPP WINDOWS !</p>
  
  <p><strong>Solution:</strong></p>
  
  <p>Because I'm using a Windows Web Server (XAMPP), I needed to specify the path:</p>
  
  <pre><code>$command = 'd:\xampp\mysql\bin\mysqldump --opt -u '.$_user.' -p'.$_pass.' '.$_db.' &gt; test.sql';
  </code></pre>
  
  <ol>
  <li>I removed the space between the -p and the pass. It looks like: <code>-pMYPASSWORD</code></li>
  <li>Replaced <code>"</code> with <code>'</code></li>
  </ol>
  
  <p>I think if you are using a Linux based web server, you don't have to specify the path for mysqldump.</p>
  
  <p>Cheers! :-)</p>