Until the early hours of the morning I have been trying to test for the existence of a file using file_exists(). If I hard code the file name it works fine but if I use a variable from a table it doesn't. Am I just stupid or what? Please help so I can get some sleep - snippet of code to demonstrate:
$filename=$row["phref"]
#note phref is Dscf0011.jpg
if (file_exists('thumb/Dscf00011.jpg')) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
#The above works
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
#The above doesn't
$filename=$row["phref"]
#note phref is Dscf0011.jpg
if (file_exists('thumb/Dscf00011.jpg')) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
#The above works
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
#The above doesn't