
 Dino L. - 2005-10-26 11:36:45
<?php
mysql_connect("localhost", "usr", "pass");
require("class_mysqldump.php");
$dump = new MySQLDump();
$somecontent = $dump->dumpDatabase("bbm");
//timestamp file name
$filename = date("Y-m-d_H_i-").'backup.sql';
//open a new file
   if (!$handle = fopen($filename, 'w')) {
         echo "Cannot open file ($filename)";
         exit;
   }
//write it
  if (fwrite($handle, $somecontent) === FALSE){
       echo "Cannot write to file ($filename)";
       exit;
   }
   fclose($handle);
//send a good header so user can choose to download file...
   header("Content-type: text/plain");
   header("Content-Disposition: attachment; filename=$filename");
   readfile($filename);
//if u like u can delete file now :) I wont ;)
?>