Weird things with file_exists

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

Post Reply
CMMDB
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 2:05 pm

Weird things with file_exists

Post by CMMDB »

Hi all! Newb here,hoping you could help..

I've got the following code:

Code: Select all

 
<?php
$FSFriendlyTitle = str_replace(':','&#58;',$VMRow['Title']);
 
echo "<h2>".$VMRow['Title']." (Season ".$VMRow['SeasonReleased'].")</h2><hr/>";
//echo "/Images/Posters/".$FSFriendlyTitle.".jpg";
if(file_exists("/Images/Posters/".$FSFriendlyTitle.".jpg"))
{
echo "<img src='/Images/Posters/".$FSFriendlyTitle.".jpg' alt='".$VMRow['Title']."'/><p/>";
}
else
{
echo "<img src='/Images/Posters/Poster Missing.jpg' alt='".$VMRow['Title']."'/><br/>";
}
?>
which is supposed to display an image file if it exists and a predefined one if it doesn't. The problem is that it always displays the predefined file, unless I negate the result from file_exists (but then the code attempts to display images that doesn't exist too). Yes, the images exist(the path is correct too, if I paste the output path[by the commented echo] into the url it works) and I have have a near identical setup with a different set of images, which works.If you need more info, just ask. Anybody got any idea here?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Weird things with file_exists

Post by onion2k »

Does it work if you put clearstatcache() at the top of the script?
CMMDB
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 2:05 pm

Re: Weird things with file_exists

Post by CMMDB »

No such luck :(

I find it so weird that the near-identical-but-different-image-set code works though..
Post Reply