【发布时间】:2015-11-09 07:45:37
【问题描述】:
我使用这个 php 代码来创建我所有 MYSQL 数据库的备份。 但它发送此错误:无法创建目录
<?php
..
..
..
..
if (mysql_select_db($db)) print "Selected [$db]\n";
else die("Failed to select db [$db]");
foreach (array("schema","data") as $pass){
$sql = mysql_query("show tables");
$day = date("l");
if ($pass=="schema") $dir = "/$backup_dir/$db/schema";
else $dir = "/$backup_dir/$db/$day";
if (!file_exists($dir)) system("mkdir -p $dir");
if (!file_exists($dir)) die("Couldn't Create $dir");
if ($pass=="data"){
$latest = ( /$backup_dir/$db/latest"; )
unlink($latest);
system("/bin/ln -s \"$dir\" \"$latest\"");
}
cleanup($dir);
if ($sql) while ($s = mysql_fetch_assoc($sql)) {
if (!isset($s["Tables_in_{$db}"])) {
print "no result";
print_r($sql);
die();
}
..
..
..
?>
使用下面的代码,我可以在我的主机中创建目录:
<?php
$structure = './depth1/depth2/depth3/';
if (!mkdir($structure, 0777, true)) {
die('Failed to create folders...');
}
?>
有没有办法结合这些代码或任何其他建议来解决这个问题?
问候 :)
【问题讨论】:
-
system("mkdir -p $dir 777") -
您正在使用 linux 操作系统?
-
感谢您的反馈。我的操作系统是 Windows 2012 r2(如果有帮助)