0

次のコードを使用してボタンのクリックでバックアップを取得しようとしています。クリックするたびに空のデータベースが取得されます。私はすべての記事を試しましたが、結果は同じです..誰かがこれを解決するのを手伝ってくれますか.

 <?php
 ob_start();

 $username = "root"; 
 $password = ""; 
 $hostname = "localhost"; 
 $dbname   = "cars";

 $command = "D:\\..\\wamp64\\bin\\mysqldump  --add-drop-table host=$hostname
--user=$username ";
 if ($password) 
    $command.= "--password=". $password ." "; 
 $command.= $dbname;
 system($command);

 $dump = ob_get_contents(); 
 ob_end_clean();

// send dump file to the output
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($dbname . "_" . 
date("Y-m-d_H-i-s").".sql"));

flush();
echo $dump;
exit();
?>
4

1 に答える 1