0

以下代码不会引发任何错误,但数据库不会备份新数据;

<?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');  



}

?>

不知道怎么回事。。

4

1 回答 1

1

两点:

  1. 我认为你必须引用你的路径

     //$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. 为什么你不使用mysqldump

该代码应该有效

       <?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>";
            }
于 2012-10-26T08:03:51.320 回答