EDITED:
1 - the $search_result['image']
prints urls like: http://www.desktopwallpaperhd.net/wallpapers/21/7/wallpaper-sunset-images-back-217159.jpg
2 - Tried removing the include and placing the codes directly in the screenshots.php but I had no changes at all.
3 - Figured that maybe I can't request functions because of the foreach loop, so i changed it to while($search_result, mysqli_fetch_array())
and making the sql consult as mysqli_query
but the page won't load
I've been searching this in google for two days and couldn't make it work and a friend of mine told me about this website, and how it works, so... To the point:
I'm trying to check if the image URL exists and if does it returns the src of the image as the url itself, if the image URL no longer exists, or never did, the image src will change to one default.
The thing is that all the URLs are in the database... Here is my php codes:
screenshots.php
<?php
echo '<div class="dv_alb_pics" id="alb_ev_pics">';
include('scripts/sug.php');
echo $evs_content.'</div>';
?>
sug.php
<?php
$images_search = $SQL->query("SELECT * FROM `screenshots` WHERE `section` = '1' AND `status` = '1' ORDER BY `date` DESC LIMIT 50;")->fetchAll();
$evs_content .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>';
foreach($images_search as $search_result) {
if(file_exists($search_result['image'])) {
$img_source = $search_result['image'];
} else {
$img_source = 'images/none.png';
}
$evs_content .= '<div class="ss_picture_rightside"><img class="ss_p_img_rightside" src="'.$img_source.'"></div>';
}
$evs_content .= '</td>
</tr>
</table>';
?>
While I was searching I saw in a post a guy saying that file_exists()
works for URLs in php 5+
Turns out that he was probably wrong because It's not working at all
I also tried some CURL
methods but when I use CURL
inside the foreach()
my screenshots page doesn't loads
I would appreciate any suggestions, thanks!