0

The following code does not throw any errors but the databases dont get backed up with new data;

<?php
include('conn.php');
$dbhost="localhost";
$dbuser="landshop_anitgop";
$dbpass="password";

$source=array("landshop_formdata.sql","landshop_clientdata.sql","landshop_blogs.sql","landshop_counter.sql","landshop_hitems.sql");

$path = '"C:/Program Files/EasyPHP-5.3.8.1/www/Landshoppe/Downloaded Dbs/"';

        $mysqldump = '"pathToExe".mysqldump.exe"';
       foreach($source as $db) {
            $dbsource= $path.$db;
            $command = "mysql -u{$dbuser} -p{$dbpass} {$db} < ".$path."backup_{$db}.sql";
       system($command,$output);
       echo "Backed Up : ".$db." Output [".print_r($output,1)."]<br>";

     //system('mysql -u <user> -p<password> dbname < filename.sql');  



}

?>

Dont know whats going wrong ..

1 Answers1

1

Two Points:

  1. I think you have to quoate your path

     //$path = "C:\Program Files\EasyPHP-5.3.8.1\www\Landshoppe/Downloaded Dbs/";
     // change this into
     $path = '"C:/Program Files/EasyPHP-5.3.8.1/www/Landshoppe/Downloaded Dbs/"';
    
  2. Why you don't use mysqldump?

This Code should work

       <?php 
           $path = '"C:/Program Files/EasyPHP-5.3.8.1/www/Landshoppe/Downloaded Dbs/"';
           $mysqldump = '"pathToExe".mysqldump.exe"';
           foreach($source as $db) {
                $dbsource= $path.$db;
                $command = $mysqldump." -u{$dbuser} -p{$dbpass} {$db} > ".$path."backup_{$db}.sql";
           system($command,$output);
           echo "Backed Up : ".$db." Output [".print_r($output,1)."]<br>";
            }
donald123
  • 5,638
  • 3
  • 26
  • 23
  • it outputs [Output 1] for each db in the loop. But does not update the data. I have edited the question with the current code. – Landshoppe LandMarket Oct 26 '12 at 09:49
  • $mysqldump = '"pathToExe".mysqldump.exe"'; please fill pathToExe with the location of the mysqldump.exe on your Filesystem eg "c:/program files/mysql/bin/mysqldump.exe" – donald123 Oct 26 '12 at 09:52