1

Hi i get this error when a cache script is included in my site..

Warning: filemtime() [function.filemtime]: stat failed for index.php in C:\xampp\htdocs\Content\content\cache.php on line 6

Here is the script:

<?php
class datemod{
    public $gmtime;
    function date($files,$dbtable,$url){
        foreach($files as $val){
            $mod=date('Y/m/d H:i:s',filemtime($val));
            $array[]=$mod;
        }
        $fmod=max($array);
        $result=mysql_query("SELECT DATE_FORMAT(pubdate,'%Y/%m/%d %H:%i:%s') AS pubdate FROM $dbtable WHERE url='$url'");
        while($row=@mysql_fetch_array($result,MYSQL_ASSOC)){
            $row[]=array('row'=>array_map('htmlspecialchars',$row));
            $pubdate=$row['pubdate'];
        }
        $maxmod=max($fmod,$pubdate);
        $this->gmtime=date('D, d M Y H:i:s T',strtotime($maxmod));
    }
    function cache($gmtime){
        if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])||isset($_SERVER['HTTP_IF_NONE_MATCH'])){
            if($_SERVER['HTTP_IF_MODIFIED_SINCE']==$gmtime){
                header('Status:304 Not Modified',true,304);
                exit();
            }
        }
        header("Last-Modified:$gmtime");
    }
}
?>

I cant seem to find whats wrong with it.. any help?

1
  • Could we see how the function is being called? A common mistake is calling filemtime() on a directory not file. Commented Apr 20, 2011 at 0:27

2 Answers 2

2

The warning is triggered because there is no file index.php in the current dir (can be retrieved using getcwd())

Sign up to request clarification or add additional context in comments.

Comments

1

It means that either file passed to filemtime() doesn't exist, or the program doesn't have permission to access its attributes.

Maybe begin by displaying or logging $val to see if it is what is expected. If all looks well there, then check the file permissions, including of every directory in the path.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.