Syntax problem when checking for a file
- by Luke
This piece of code has previously worked but I have C&P it to a new place and for some reason, it now won't work!
<?
$user_image = '/images/users/' . $_SESSION['id'] . 'a.jpg';
if (file_exists(realpath(dirname(__FILE__) . $user_image)))
{
echo '<img src="'.$user_image.'" alt="" />';
}
else
{
echo '<img src="/images/users/small.jpg" alt="" />';
}
?>
As you can see, I am checking for a file, if exists, showing it, if not, showing a placeholder.
The $_SESSION['id'] variable does exist and is being used elsewhere within the script.
Any ideas what the problem is?
Thanks