Solved

Warning : mkdir filetools.inc line 55 - PLEASE HELP

Posted on 2004-08-31
10
243 Views
Last Modified: 2006-11-17
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($filename));
   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\$$arname=array(\n");
   if (is_array($ar)) {
      reset($ar);
      foreach($ar as $key=>$val) {
         $key=str_replace("\"","\\\"",$key);
         $val=str_replace("\"","\\\"",$val);
         fputs($fp,"\"$key\"=>\"$val\",\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-$si);
   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,$pattern="*.*") {
   if (is_dir($filepath)) {
#      foreach (glob("$filepath/$pattern") as $filename) {
#         if (is_file("$filepath/$filename")) unlink("$filepath/$filename");
#      }
      if ($fp = opendir($filepath)) {
         while (($filename = readdir($fp)) !== false) {
            if (is_file("$filepath/$filename")) unlink("$filepath/$filename");
         }
      }
   }
}
?>

0
Comment
Question by:wcws
  • 5
  • 4
10 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11947909
what is the content of $filepath?
0
 

Author Comment

by:wcws
ID: 11947918
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
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 11949697
Try this:

if (!file_exists($filepath))
    $res=mkdir($filepath,0777);
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:wcws
ID: 11950646
I am getting same error ?
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 11954120
Does your error mesasge include anything more specific like:

Warning: mkdir() failed (Permission denied) in /home/virtual/domain.com/filetools.inc on line 55
0
 

Author Comment

by:wcws
ID: 11954538
checking for spiders...

Warning: mkdir(/news/pages/1/): No such file or directory in /home/virtual/site4/fst/var/www/html/news/filetools.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
0
 
LVL 4

Accepted Solution

by:
iceboxman earned 50 total points
ID: 11954653
OK, are you trying to create /news/pages/1/?  I think I see what the problem might be.  Is /news located off the root or inside of /home/virtual/domain.com/

If it is located inside of /home/virtual/domain.com/ then try either ./news/pages/1/ or news/pages/1/

Remember this is relative to the location of the script creating the directory.  Also check that ./news and ./news/pages exists prior to creating the /1 /2 and /3 directories.
0
 

Author Comment

by:wcws
ID: 11954918
the news is located inside /home/virtual/site4/fst/var/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
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 11955116
Where is filetools.inc located?
0
 

Author Comment

by:wcws
ID: 11955130
That file is located in

/home/virtual/site4/fst/var/www/html/news/

Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question