Hey all,
I'm trying to use file_exists() in order to recognize if an image exists according to the path given in a DB entry... and if not, it displays a default graphic.. but even with the image in the right place, it fails:
PHP Code:
$photo_directory = "http://www.fasports.com/az/phx/images/champions/"; $default_photo = "http://www.fasports.com/az/phx/images/champions/player_silhouette.jpg";
<? while($sat_wv_row = mysql_fetch_array($saturdays_wv)){ ?>
<td>
<?php $photo_url = $photo_directory.$sat_wv_row['photourl']; if(file_exists($photo_url)) { } else { $photo_url = $default_photo; } ?> <center> <a href="<? echo $photo_url; ?>" class="blue" title="View <? echo ($sat_wv_row['team']); ?>'s Team Photo" target="_blank"> <img src="<? echo $photo_url; ?>" width="125"></a><br/> <b><? echo ($sat_wv_row['division']); ?></b><br/> <? echo ($sat_wv_row['team']); ?> </center> </td> <? } ?>
One example of a DB entry being spit out would have the $photo_url of:
"2010/winter/saturday_ev_competitive.jpg"
So if you combined the $photo_directory and $photo_url, you'd wind up with:
http://www.fasports.com/az/phx/image...ompetitive.jpg
If you try the link, you'll see the image does indeed exist.
Any ideas where I'm going wrong with my usage of file_exists()?
Thanks for the help!
|