title: backup mysql tables with php
body: <p>I would like to backup tables <code>(with PHP)</code> from a db if the table prefix is matching with a sub string. What I was trying and is not working</p>
  
  <pre><code>error_reporting(1);
  $dbname = 'wp_dev';
  
  if (!mysql_connect('127.0.0.1', 'root', '')) {
      echo 'Connection Error';
      exit;
  }
  
  $sql = "SHOW TABLES FROM $dbname LIKE 'wp_%'";
  $result = mysql_query($sql);
  
  if (!$result) {
      echo "DB tables could not be listed\n";
      echo 'MySQL Fehler: ' . mysql_error();
      exit;
  }
  
  while ($row = mysql_fetch_row($result)) {
      echo "&lt;pre&gt;Table: {$row[0]}\n&lt;/pre&gt;";
      system( 'mysqldump $dbname $row[0] &gt; verlag_$row[0].sql');
  }
  
  mysql_free_result($result);
  </code></pre>