wcws
asked on
Warning : mkdir filetools.inc line 55 - PLEASE HELP
I am having some serious problem with my script.
When I run my script I always got Warning:mkdir filetools.inc line 55
Just so you all know I already have a directory created in my server , I've tried to delete the directory and create it again and but still I am getting that stupid Warning: mkdir error, Please help me anyone.
My line # 55 is
========
$res=mkdir($filepath,0777) ;
========
My Whole Script is listed as follows :-
===
<?php
function wrt($filename,$var) {
$fp=fopen($filename,"w") or goback("cannot write $filename");
fputs($fp,$var);
fclose($fp);
}
function append($filename,$var) {
$fp=fopen($filename,"a") or goback("cannot append to $filename");
fputs($fp,$var);
fclose($fp);
}
function rd($filename) {
$fp=fopen($filename,"r") or goback("cannot read $filename");
$var=fread($fp,filesize($f ilename));
fclose($fp);
return $var;
}
function wrtarray($filename,$ar) {
$si=strrpos($filename,"/") ;
if ($si===false) $si=-1;
$ei=strrpos($filename,".") ;
if ($ei===false) $ei=strlen($filename);
$si++;
$arname=substr($filename,$ si,$ei-$si );
$fp=fopen($filename,"w") or goback("cannot write $filename");
fputs($fp,"<"."?php\n\$$ar name=array (\n");
if (is_array($ar)) {
reset($ar);
foreach($ar as $key=>$val) {
$key=str_replace("\"","\\\ "",$key);
$val=str_replace("\"","\\\ "",$val);
fputs($fp,"\"$key\"=>\"$va l\",\n");
}
}
fputs($fp,");\n?".">");
fclose($fp);
}
function wrtvar($filename,$var) {
$si=strrpos($filename,"/") ;
if ($si===false) $si=-1;
$ei=strrpos($filename,".") ;
if ($ei===false) $ei=strlen($filename);
$si++;
$varname=substr($filename, $si,$ei-$s i);
wrt($filename,"<"."?php\n\ $$varname= $var;\n?". ">");
}
function makesubdir($filepath) {
if (!is_dir($filepath)) {
$oldumask = umask(0);
$res=mkdir($filepath,0777) ;
umask($oldumask);
} else $res=true;
return $res;
}
function eraseall($filepath,$patter n="*.*") {
if (is_dir($filepath)) {
# foreach (glob("$filepath/$pattern" ) as $filename) {
# if (is_file("$filepath/$filen ame")) unlink("$filepath/$filenam e");
# }
if ($fp = opendir($filepath)) {
while (($filename = readdir($fp)) !== false) {
if (is_file("$filepath/$filen ame")) unlink("$filepath/$filenam e");
}
}
}
}
?>
When I run my script I always got Warning:mkdir filetools.inc line 55
Just so you all know I already have a directory created in my server , I've tried to delete the directory and create it again and but still I am getting that stupid Warning: mkdir error, Please help me anyone.
My line # 55 is
========
$res=mkdir($filepath,0777)
========
My Whole Script is listed as follows :-
===
<?php
function wrt($filename,$var) {
$fp=fopen($filename,"w") or goback("cannot write $filename");
fputs($fp,$var);
fclose($fp);
}
function append($filename,$var) {
$fp=fopen($filename,"a") or goback("cannot append to $filename");
fputs($fp,$var);
fclose($fp);
}
function rd($filename) {
$fp=fopen($filename,"r") or goback("cannot read $filename");
$var=fread($fp,filesize($f
fclose($fp);
return $var;
}
function wrtarray($filename,$ar) {
$si=strrpos($filename,"/")
if ($si===false) $si=-1;
$ei=strrpos($filename,".")
if ($ei===false) $ei=strlen($filename);
$si++;
$arname=substr($filename,$
$fp=fopen($filename,"w") or goback("cannot write $filename");
fputs($fp,"<"."?php\n\$$ar
if (is_array($ar)) {
reset($ar);
foreach($ar as $key=>$val) {
$key=str_replace("\"","\\\
$val=str_replace("\"","\\\
fputs($fp,"\"$key\"=>\"$va
}
}
fputs($fp,");\n?".">");
fclose($fp);
}
function wrtvar($filename,$var) {
$si=strrpos($filename,"/")
if ($si===false) $si=-1;
$ei=strrpos($filename,".")
if ($ei===false) $ei=strlen($filename);
$si++;
$varname=substr($filename,
wrt($filename,"<"."?php\n\
}
function makesubdir($filepath) {
if (!is_dir($filepath)) {
$oldumask = umask(0);
$res=mkdir($filepath,0777)
umask($oldumask);
} else $res=true;
return $res;
}
function eraseall($filepath,$patter
if (is_dir($filepath)) {
# foreach (glob("$filepath/$pattern"
# if (is_file("$filepath/$filen
# }
if ($fp = opendir($filepath)) {
while (($filename = readdir($fp)) !== false) {
if (is_file("$filepath/$filen
}
}
}
}
?>
what is the content of $filepath?
ASKER
the location of that directoy is
/home/virtual/domain.com/ and so on.
the directory structure looks like
pages/1
pages/2
pages/3
the contents is images and html files .
Thanks
/home/virtual/domain.com/ and so on.
the directory structure looks like
pages/1
pages/2
pages/3
the contents is images and html files .
Thanks
Try this:
if (!file_exists($filepath))
$res=mkdir($filepath,0777) ;
if (!file_exists($filepath))
$res=mkdir($filepath,0777)
ASKER
I am getting same error ?
Does your error mesasge include anything more specific like:
Warning: mkdir() failed (Permission denied) in /home/virtual/domain.com/f iletools.i nc on line 55
Warning: mkdir() failed (Permission denied) in /home/virtual/domain.com/f
ASKER
checking for spiders...
Warning: mkdir(/news/pages/1/): No such file or directory in /home/virtual/site4/fst/va r/www/html /news/file tools.inc on line 57
Although there is a directory there in the name news/pages/1 but I dont understand why its messing up ? Please help
Warning: mkdir(/news/pages/1/): No such file or directory in /home/virtual/site4/fst/va
Although there is a directory there in the name news/pages/1 but I dont understand why its messing up ? Please help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the news is located inside /home/virtual/site4/fst/va r/www/html /news/
my question is where should I mention this
./news/pages/1/ or news/pages/1/
If you mean in the configuration file than my configuration file looks like this
$imagesdir="news/images"; #subdirectory to place images within newdomain
$pagesdir="news/pages"; #subdinewdomain
I tried both the example you mentioned but none of them work.
Thanks
my question is where should I mention this
./news/pages/1/ or news/pages/1/
If you mean in the configuration file than my configuration file looks like this
$imagesdir="news/images"; #subdirectory to place images within newdomain
$pagesdir="news/pages"; #subdinewdomain
I tried both the example you mentioned but none of them work.
Thanks
Where is filetools.inc located?
ASKER
That file is located in
/home/virtual/site4/fst/va r/www/html /news/
Thanks
/home/virtual/site4/fst/va
Thanks