title: mysqldump of all databases on Windows 7 with PHP
body: <p>I am trying to execute mysqldump to export all databases with a small PHP script, but i am stuck with a empty file being created every time the code is executed.</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', '1');
  
  $filename='database_backup_'.date('G_a_m_d_y').'.sql';
  
  $result=exec('mysqldump -p123456 -uroot --all-databases --single-transaction &gt; C:\\tmp' . $filename,$output);
  
  if($output==''){
      echo("Success");
  }
  else {
      var_dump($output);
  } 
  
  ?&gt;
  </code></pre>
  
  <p>I have tried to <code>print_r</code> the <code>$output</code> but obviously this is empty even when my dump fails. I have executed the identical mysqldump manually with mysqldump.exe which works out fine.</p>
  
  <p>Suggestion with passthru did the trick:</p>
  
  <pre><code>passthru('C:\wamp\bin\mysql\mysql5.5.24\bin\mysqldump.exe -uroot -p123456 --all-databases --single-transaction &gt; C:\\tmp' . $filename);
  </code></pre>