Forum Moderators: coopster

Message Too Old, No Replies

Images not loading (using Include )

Images not loading coming from other site.

         

kenchix1

4:49 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



I have two websites, one is a forum website and one is an free ads. I inserted this code inside display template of the forum (SMF) after the message info portion :

include 'pickimage.php';

pickimage.php should get 4 thumbnails/images and links from my other site and display it on the header part. But I noticed that most of the time the picture isn't loaded. The hotlink protection is also disabled.

is there a way to wait or make sure the images are loaded before the remaining portion of the display template code executes?

Thanks in advance.

jenningsdev

7:31 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



I amy be able to help if I have more info.

Shane

Birdman

7:40 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, we should see pickimage.php in order to help.

coopster

11:05 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




is there a way to wait or make sure the images are loaded before the remaining portion of the display template code executes?

The process will finish the include before it moves onto the next line in your script. You could monitor for any unsuccessful image retrieval and handle accordingly.

jenningsdev

11:23 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Yes, I agree. Maybe you should try pushing the files names into an array and checking for their existence before letting the script finish.

using array_push() [php.net...] and in_array()
[php.net...]

If the files are not found maybe have a set of default images that are used so you at least get an image or an alternate path to the files.

kenchix1

2:26 am on Apr 6, 2006 (gmt 0)

10+ Year Member



Thank you very much for the replies. here's the code of pickimage.php (domains and tablenames had been replaced) :


<table align='center'><tr>

<?php

include 'config.php';
include 'opendb.php';

$query="SELECT `image_url_table`.`thumb_url` , `ads_table`.`title` , `image_url_table`.`classified_id` , `ads_table`.`price`FROM `image_url_table` , `ads_table`WHERE `image_url_table`.`classified_id` = `ads_table`.`id`ORDER BY rand() LIMIT 4 ";

$result = mysql_query($query);

while(list($picture,$title,$id,$price)= mysql_fetch_row($result))

{

$imgloc="http://www.my_ads_website.com/ads/$picture";

echo "<td width='27%' align='center' style='border-left: 1px solid rgb(0,64,128); border-bottom: 1px solid rgb(0,64,128); border-right: 1px solid rgb(0,64,128); border-top: 1px solid rgb(0,64,128) ';><font size='-2' face='verdana,helvetica,arial'><a target='_new' href='http://www.my_ads_website.com/ads/index.php?a=2&b=$id'><img src='$imgloc' border='0'></a><br><a class='link3' href='http://www.my_ads_website.com/ads/index.php?a=2&b=$id'>",stripslashes(urldecode($title)),"</a><br>",stripslashes(urldecode($price)),"<br></font></td>";

}

include 'closedb.php';

?>

</tr></table>

Birdman

7:39 pm on Apr 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try printing the image location to the page to see if they are corrupt.

$imgloc="http://www.my_ads_website.com/ads/$picture";

// add this after line above
print $imgloc;
// end debug