Hi guys! Is there anyone can help me to do import and export database from my sql? i don't have any idea how to do it. I don't want to do it manually which is using phpmyadmin. So, i want to make it easy only by click the export button. This is what i've already got
ob_start();
$username = "root";
$password = "1234";
$hostname = "localhost";
$dbname = "annualreport1";
// if mysqldump is on the system path you do not need to specify the full path
// simply use "mysqldump --add-drop-table ..." in this case
$command = "C:\\AppServ\\MySQL\\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();
but this error keep showed up
Warning: Cannot modify header information - headers already sent in C:\AppServ\www\FSAS\export.php on line 22
Warning: Cannot modify header information - headers already sent in C:\AppServ\www\FSAS\export.php on line 23
Warning: Cannot modify header information - headers already sent in C:\AppServ\www\FSAS\export.php on line 24
Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR mysqldump [OPTIONS] --all-databases [OPTIONS] For more options, use mysqldump --help
Your help are much appreciated.