View Full Version : how can you test if an image loads / file exists?

10-19-2009, 02:10 PM
I would like to write a php script that selects a large number of images paths/filenames on my server that I have stored in this mySQL table -- if the file doesn't exist on the server then I would like the id for that table item displayed

$sql="SELECT id,imageFilename FROM userTable LIMIT 1000"
$result = mysql_query($sql);

if(what condition would I use in here to check to see if the file exists or loads?){
echo '<p>this id '.$row[id].' needs to be fixed as it does not exist</p>';


10-19-2009, 02:15 PM
file_exists() (http://php.net/file_exists) ?

10-19-2009, 09:18 PM
I don't think there's anything wrong with storing images in the MySQL database
instead of in a sub-directory, but when it comes to manipulating them, it's so much
easier when they reside on the website (not the MySQL database). Your problem is
a case-in-point where storing in a directory would be so much easier.

I'm still looking for the answer to your question.

10-25-2009, 07:16 PM
silly me


u rock