PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ozzy
Forum Commoner
Posts: 74 Joined: Tue Apr 11, 2006 4:45 pm
Post
by ozzy » Sun Apr 16, 2006 8:25 am
Im getting the following error message:
Code: Select all
filemtime() [function.filemtime]: stat failed for *FILENAME* on line 45
December 31 1969 19:00:00.
This occurs when i use the filemtime() function in my page:
Code: Select all
. date ("F d Y H:i:s.", filemtime($filename))
I tryed searching google for awnsers, but all it is returning is sites which are suffering from this error. Ehat is the meaning behind this error message, and how do i reslove it?
Thanks in advance.
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sun Apr 16, 2006 9:05 am
I believe it's unable to determine the last modified time from the file for what ever reason (maybe corruption). You can try muting the error like this:
Code: Select all
date ("F d Y H:i:s.", @filemtime($filename))
But it will still give you this bogus date (December 31 1969 19:00:00.) Alternatively... you can do this.
Code: Select all
function smart_filemtime($filename) {
$time = @filemtime($filename);
if ($time) return $time;
else return time();
}
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sun Apr 16, 2006 9:08 am
What is the last modification time of the file?
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Apr 16, 2006 9:22 am
Oren wrote: What is the last modification time of the file?
the time the file was last modified
--
Have you tried checking for the files exisance before running it through filemtime?
ozzy
Forum Commoner
Posts: 74 Joined: Tue Apr 11, 2006 4:45 pm
Post
by ozzy » Sun Apr 16, 2006 9:31 am
Ambush Commander wrote: I believe it's unable to determine the last modified time from the file for what ever reason (maybe corruption). You can try muting the error like this:
Code: Select all
date ("F d Y H:i:s.", @filemtime($filename))
But it will still give you this bogus date (December 31 1969 19:00:00.) Alternatively... you can do this.
Code: Select all
function smart_filemtime($filename) {
$time = @filemtime($filename);
if ($time) return $time;
else return time();
}
Its seems to disable the error message being displayed but it dosnt reslove the error.
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sun Apr 16, 2006 9:32 am
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Apr 16, 2006 9:34 am
Ah, well the OP told us December 31 1969 19:00:00 is the resulting from filemtime, so I was a bit confused by your post.
Either way, to repeat my last post ozzy, did you run the file through file_exists() first to assure your paths are set correctly?
ozzy
Forum Commoner
Posts: 74 Joined: Tue Apr 11, 2006 4:45 pm
Post
by ozzy » Sun Apr 16, 2006 9:48 am
its not that the files dosnt exist, i know this becouse the are being returned in the same script using glob or opendir, its just that the times arent being returned. Even so, i tryed file_exists and im still getting the same problem; file being returned successfully, but not the time.
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sun Apr 16, 2006 9:52 am
Jcart: You still get me wrong... I saw what the returned date was. I'm asking what is the real modification date like when you Right Click->Prpperties and then you check under "Last modified: [date_here]" (on Windows).
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Apr 16, 2006 9:53 am
What's $filename in this particular case?
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sun Apr 16, 2006 9:57 am
Try to use the filectime() function and tell us whether it works or not (just as a test not instead of filemtime()).
ozzy
Forum Commoner
Posts: 74 Joined: Tue Apr 11, 2006 4:45 pm
Post
by ozzy » Sun Apr 16, 2006 9:58 am
What's $filename in this particular case?
Filename:
Code: Select all
$files = glob($dir . 'vuns/files/*');
foreach ($files as $path) {
$filename = basename($path);
Try to use the filectime() function and tell us whether it works or not (just as a test not instead of filemtime()).
I still get the same error
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sun Apr 16, 2006 10:05 am
Ok, what is the OS you are using to run this script?
What is the last modification date of the file? I mean the real one (check manually).
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Apr 16, 2006 10:06 am
Code: Select all
$files = glob($dir . 'vuns/files/*');
foreach ($files as $path) {
echo filemtime($dir.$path);
}
are you sure your pointing the file along with the dir like so?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Apr 16, 2006 10:11 am
the usage of
basename() explains why. The file doesn't exist in the local directory, so
filemtime() can't find the file.