以下代码不会引发任何错误,但数据库不会备份新数据;
<?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');
}
?>
不知道什么是错的..
答案 0 :(得分: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/"';
为什么不使用 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>";
}