Hi, i am using a thumbnail script to display smaller versions of photos on a website.

The paths to the high res pictures are stored in a DB, and i have been looping through the DB to take the path, and run it through a thumbnail generator script, which outputs a jpg file.

This works fine for a batch of photos less than 10, anymore than this and some of the pictures display as broken links, yet when i click "show picture" it displays it.

Which would suggest that the php script is simply skipping some pictures, due to the sheer amount. But this happens after 10, and the high res versions are only 400 pixels by 300, jpeg photos?!!

Ive tried using set_time_limit() but this doesnt help! Any one got any other ideas?

The code im using is ....

The loop which displays the pics ....

<?php
	$sql = "SELECT picture_path FROM loc_pictures WHERE gallery_id = '$_GET[gallery]'";
	$result = mysql_query($sql);

echo "<p><u><i>";
echo $num = mysql_num_rows($result) . " pictures found";
echo "</u></i></p>";
echo "<p align = 'center'>";

while ($row = mysql_fetch_array($result))
{
 echo "<a href = '$row[picture_path]' rel = 'lightbox'>";
 echo "<img src='thumb.php?filename=$row[picture_path]' border = '0' /></a>";
 echo "&nbsp;";

}

echo "</p>";


?>

and the thumbnail script is ....

<?php
// File and new size
$percent = 0.25;

// Content type
header('Content-type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor(100, 75);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, 100, 75, $width, $height);

// Output
imagejpeg($thumb);
?>

    before going down that route, it's a good idea to right click on one of the "broken" thumbs, and copy the path (which will obv be thumb.php?filename=xxx etc). then paste that as the address in a new browser window/tab and check that teh thumb is in fact generated okay. If you get a 404 error, then you know it's a problem with what's being pulled out of the DB rather than a problem with the thumb generation script.

    give that a go, and if it's all okay, then come back.

      Hi, cheers for the reply.

      I forgot to mention that. I did type the post out once, and deleted it by accident, and thought id mentioned it!

      The broken links vary between refreshes, and when i click show picture the picture then appears in the place it should do. SO its not a case of the DB path being wrong, or the picture genuinly not being there, its definatly the script not loading the images. Because it sometimes affects other images on the page, which arent anything to do with the loop/thumbs!!

      It also works if i cut and paste the address thumb.php?filename=bla_bla.jpg into a new window too!!

        can you post the page on your server so we can see it live?

          really? thats odd, its still not showing on my browser. In firefox it doesnt show correctly, nor in IE, but in aol its fine?!

          What browser you using?! Should that make a difference??!

            Even though the title states "15 pics found", as it is using mysql_num_rows() there are never 15 full pictures there for me!

              Yeah, thats what i mean! Every refresh produces different selections of results, and its always on the thumbs over the 10 mark!

              So its gotta be a problem with loading more than 10 thumbs right???

                a month later

                Did you sort out your problem with the thumbs ?

                If so can you post your solution as I will benefit from it. 🙂

                  Write a Reply...