I am also trying to do something similar to this, but I am having some difficulty with it. I think this is because I am trying to check to see if a file exists, but the actual file that I am checking will vary based on what page is being pulled up. For example, I am trying to display a player image on a page. This player image depends on the player's name and if there is no photo, it will display a generic image. So this is what I have...
$playername = $row['name'];
$playerpic = '/poker/images/players/$playername.gif';
if( is_file($playerpic) ){
echo "<table width=\"400\" border=\"0\">";
echo "<tr><td rowspan=\"3\"><center><img src=\"http://www.mysite.net/poker/images/players/$playername.gif\"><br/> <strong><FONT SIZE=\"5\">$playername</FONT></strong><br/></td></tr>";
echo "</table>";
echo "<br/>";
}
However, it is always reverting to the else statement photo. I know the files are uploaded and that is the correct location, it has to be the $playername.gif part of the code that is giving me the issue. What is another way to accomplish this? Thanks!