Getting empty .sql file when we run backup code please see the code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guys

i have the code for  taking the database backup when i run the code i
am getting empty file with out tables. fallowing is my code please
provide some help.


<?php


$dbname = 'bulksms' ;
$dbuser = 'root';
$dbpass = '';
$dbhost = 'localhost';;


$connect=mysql_connect($dbhost,$dbuser,$dbpass);
  mysql_select_db($db);
  //echo "jumbedb selected";
 mysql_select_db($dbname)or die("cannot select DB");


//$backupFile = $dbname . date("Y-m-d-H-i-s") . '.sql';
$backupFile = $dbname.'.sql';

/*
        header('Content-Description: File Transfer');
        header('Content-Type: application/force-download');
        header ("Content-Type: application/octet-stream");
        header("Content-Length: ".filesize("$folder/$file"));
        header('Content-Disposition: attachment; filename=' . $file);
        readfile("$folder/$file");
*/
  // mysqldump ---user admin ---password=$dbpass mydatabase > sql.dump

	//$command = "mysqldump --opt -h $dbhost -u $dbuser
--password=$dbpass $dbname > $backupFile";
	//$command = "mysqldump --opt -h $dbhost -u $dbuser
--password=$dbpass $dbname";
	    $command="mysqldump ---user $dbuser ---password=$dbpass $dbname"; 
	//echo "command is".$command;
	exec($command,$retval);

	$user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);

	if ( (is_integer (strpos($user_agent, "msie"))) && (is_integer
(strpos($user_agent, "win"))) ){
        //header('Cache-Control: must-revalidate, post-check=0,
pre-check=0');
        //header('Pragma: public');
		//header('Content-Type: xxx/null');	
		//header('Content-Disposition: attachment; filename="' . $backupFile
. '";');
	} else {
		//header('Content-Type: application/octet-stream');
        //header('Content-Disposition: attachment; filename="' .
$backupFile . '";');
        //header('Pragma: no-cache');
	}
	header('Content-Description: File Transfer');
	header('Content-Type: application/force-download');
	header ("Content-Type: application/octet-stream");
	header('Content-Disposition: attachment; filename=' . $backupFile);
	//header('Content-Length: ' . strlen($retval));
	//readfile($backupFile); 
	//print_r( $retval);
	foreach($retval as $val)
		echo $val."\n";


?>


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux