这个密码怎么了?我正在使用链接调用下面的代码。还需要别的什么才能起作用吗?错误具体地说是
这一行:
$backupdir = 'C:\wampbackup\x.sql';
有什么可能解决这个问题。我是个初学者,请忍受我知识的缺乏。
$host= 'localhost';
$user= 'root';
$pass= '';
$db= 'hospital;
$backupdir = 'C:\wampbackup\x.sql';
// Compute day, month, year, hour and min.
$today = getdate();
$day = $today[mday];
if ($day < 10) {
$day = "0$day";
}
$month = $today[mon];
if ($month < 10) {
$month = "0$month";
}
$year = $today[year];
$hour = $today[hours];
$min = $today[minutes];
$sec = "00";
// Execute mysqldump command.
// It will produce a file named $db-$year$month$day-$hour$min.gz
// under $DOCUMENT_ROOT/$backupdir
system(sprintf(
'mysqldump --opt -h %s -u %s -p%s %s | gzip > %s/%s/%s-%s%s%s-%s%s.gz',
$host,
$user,
$pass,
$db,
getenv('DOCUMENT_ROOT'),
$backupdir,
$db,
$year,
$month,
$day,
$hour,
$min
));
echo '+DONE';
?>
最佳答案
更改此行:
$backupdir = 'C:\wampbackup\x.sql';
进入:
$backupdir = 'C:\\wampbackup\\x.sql';
你需要用另一个反斜杠来逃避反斜杠。:)