I want to create a backup from a database, but I get only a blank file.
include(\'config.php\');
$command = \"mysqldump --opt -h \".$_host.\" -u \".$_user.\
Try this:
$DBUSER="user";
$DBPASSWD="password";
$DATABASE="DBname";
$filename = "backup-" . date("d-m-Y") . ".sql";
$command = '"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" '.$DATABASE ." -u".$DBUSER ." -p".$DBPASSWD." > your_web_site/$filename";
passthru($command);
Then force the download of the file:
if (file_exists("your_web_site/".$filename)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile("your_web_site/".$filename);
exit;
}
Edit: You have to give permissions to the folder where you keep copies.