Hi I am trying to get image thumbnails to display on the page. The page displays one large image at the top (code not included since it works fine), and below it are supposed to be 5 smaller thumbnails of images the visitor may also be interested in viewing.
Below is the code for displaying the thumbnails, but i get this error message:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/view_photo.php on line 50
Line 50 is shown through the comment.
if(isset($_GET['imageid'])) {
$imageid = (int) $_GET['imageid'];
echo "<h3><font color=#C12267>You may also be interested in these images:</font></h3>";
$query2 = "SELECT right FROM rules WHERE left='$imageid' LIMIT 5";
$result2=mysql_query($query2);
while($row2=mysql_fetch_assoc($result2)) { //THIS IS LINE 50
if (!file_exists('thumbnails/'.$row2['imagepath'])) {
/* Thumbnail generation */
$im = @imagecreatefromjpeg($row2['imagepath']);
if($im) {
$width = imagesx($im);
$height = imagesy($im);
$scale = min( 150 / $width, 150 / $height);
$newwidth = $width * $scale;
$newheight =$height * $scale;
$im2 = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($im2, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($im2, "thumbnails/" . $row2['imagepath']);
}
}
echo '<a href="view_photo.php?imageid='.$row2['imageid'].'">';
echo '<img src="thumbnails/'.$row2['imagepath'].'"/></a><br/><br />';
}
}
Please can someone help me? Thank you in advance