I created a database backup script with options to download backup, save backup onto server, or display backup on browser:
Something is wrong when I attempt to download the backup. The file is empty.
Here is the code:
if ($method == "download") {
// GET CURRENT DATE
$date = date("m-d-y_H-i");
// WRITE TEMP FILE
$filehandle = fopen("../lib/backup/backup-$date.sql", 'w');
$result = mysql_query('SHOW tables');
while ($currow = mysql_fetch_array($result, MYSQL_NUM)) {
sql_info($currow[0], $filehandle, $method);
fwrite($filehandle, "\n\n\n");
}
fwrite($filehandle, "### DATABASE BACKUP COMPLETED ###");
fclose($filehandle);
header("Content-Disposition: attachment; filename=http://localhost/calvin/lib/backup/backup-$date.sql");
header("Content-type: unknown/unknown");
die;
}
Thanks.
-CALV1N