I am using the file_exist function in php and it doesn't seem to be working correctly.
What I am doing is I have a database that holds vehicles and I am using the stock number to match the image name. This pulls the information from the database and and than search's the folder for the vehicle image to see if it exists so I can tell which items have an image and which ones do not. This doesn't seem to be working. Can anyone tell why, here is the code:
$query = "SELECT * FROM $db_table";
if ($result = mysql_query($query, $connection)) {
while ($a_row = mysql_fetch_array($result)) {
$myVehicle= "folderPath/".$a_row['stock'].".jpg";
if (file_exists($myVehicle)){
echo "pic is available:";
echo $a_row['stock'];
} else {
echo "no pic available:";
echo $a_row['stock'];
}
}
}
I am not getting any errors, it just gives all the results as if the file doesn't exist
I tried a similiar script that opens the script and tests whether it is there and this works. The problem is I have is there are over 300 images and this can take a long time to process. I thought the file_exist function would work bettter.
Any thoughts on this, I would appreciate it, thanks for your time