Hi,

I have spent hundreds of hours fixing errors with my phpauction GPL V2.51 script I bought. A lot have been cosmetic but this one is causing onscreen errors and making the page extremely slow to load.

To cut a long story short, if the thumbnail image a customer is linking to or has uploaded is not available for some reason, I get a "Division by Zero" error involving the file thumbimage.php

I have tried to fix it with no success. The database (I assume) knows what to look for and if it isn't there I get the onscreen errors.

Is there a way to get it to display the default "noimage.gif" picture instead of just spitting the dummy? I thought the coding did that at the bottom, but it doesn't.

This is extremely annoying because if, say a seller's Photobucket goes down - so does my website!

Here is the file code:

<?
	$pict_url = mysql_result($result, $i, "pict_url");
	$pict = "uploaded/$pict_url";
	$phu = intval(mysql_result( $result,$i,"photo_uploaded") &&($pict_url!=''));
	if ($pict_url != "") {
		if ( $phu) {$pict_url = $pict;
		}
		       	   $f_size = @getimagesize($pict_url);
			    $width = $f_size[0];
			    $height = $f_size[1];
			    
			    $x_ratio = $max / $width;
			    $y_ratio = $max / $height;
			    
			    if (($width <= $max) && ($height <= $max)) {
			      $tn_width = $width;
			      $tn_height = $height;
			    }
			    
			    else if (($x_ratio * $height) < $max) {
			      $tn_height = ceil($x_ratio * $height);
			      $tn_width = $max;
			    }
			    
			    else {
			      $tn_width = ceil($y_ratio * $width);
			      $tn_height = $max;
			    }
			   
			    $thumbnail = "<a href=\"item.php?id=$id\"><IMG SRC=\"$pict_url\" width=\"$tn_width\" height=\"$tn_height\" border=\"0\" alt=\"See more details for $title\">"."</a>";
			    
			    $tplv[img] = "<a href=\"item.php?id=".$row[id]."\">"."<IMG SRC=\"$pict_url\" width=\"$tn_width\" height=\"$tn_height\" border=\"0\" alt=\"See more details for $title\">"."</a>";
			    
			    $tplv .= "<a href=\"item.php?id=".$row[id]."\">"."<IMG SRC=\"$pict_url\" width=\"$tn_width\" height=\"$tn_height\" border=\"0\" alt=\"See more details for $title\">"."</a>";
			    
			  }
			  
			  else {
			    $thumbnail = "<img src=\"images/nopicture.gif\" width=75>";
			    $tplv[img] = "<img src=\"images/nopicture.gif\" width=75>";
			    $tplv .= "<img src=\"images/nopicture.gif\" width=75>";
	  }
	  ?>

This is the only major problem I seem to have left and any help would be greatly appreciated.

Thanks in advance,

Graham

Recommended Answers

All 6 Replies

HI, I don't know if this will help but I have a simlar php page in my project and I get a defaul image with the if statement like this:

if(!empty($pict_url))

Try changing you if statement from

if ($pict_url != "")

to the above if statement. It it doesn't wor4k let me know and I will try to figure something out.

Sorry Pomona,

That had no effect.

The problem is it's not empty, but the image it is looking for (and remebers) is not currently there.

I will narrow the problem down a little.

The uploaded images were lost yesterday while I was tweaking the website. That is not a real problem, as I simply uploaded dummy images.

The main worry is when a seller has simply linked to an image on another website. If that website goes down, I get the screen errors when I haven't actually done anything wrong.

The more images that are down, the longer the list of screen error messages, which you can imagine would really annoy visitors.

So what I really need is some way of going to the default nopicture.gif when an image link is down.

I hope that makes the problem better to understand and hopefully fix.

While I still have the chance to edit this post, my gut feeling is to find a workaround for when "pict_url" encounters a 404 (or whatever it's getting) error from the linked website, if that helps any.

Graham

Maybe you should switch the script around alittle. Try the following.

<?
	$pict_url = mysql_result($result, $i, "pict_url");
	$pict = "uploaded/$pict_url";
	$phu = intval(mysql_result( $result,$i,"photo_uploaded") &&($pict_url!=''));
	if ($pict_url != "") {
			    $thumbnail = "<img src=\"images/nopicture.gif\" width=75>";
			    $tplv[img] = "<img src=\"images/nopicture.gif\" width=75>";
			    $tplv .= "<img src=\"images/nopicture.gif\" width=75>";
	  }
			  else {

		if ( $phu) {$pict_url = $pict;
		}
		       	   $f_size = @getimagesize($pict_url);
			    $width = $f_size[0];
			    $height = $f_size[1];
			    
			    $x_ratio = $max / $width;
			    $y_ratio = $max / $height;
			    
			    if (($width <= $max) && ($height <= $max)) {
			      $tn_width = $width;
			      $tn_height = $height;
			    }
			    
			    else if (($x_ratio * $height) < $max) {
			      $tn_height = ceil($x_ratio * $height);
			      $tn_width = $max;
			    }
			    
			    else {
			      $tn_width = ceil($y_ratio * $width);
			      $tn_height = $max;
			    }
			   
			    $thumbnail = "<a href=\"item.php?id=$id\"><IMG SRC=\"$pict_url\" width=\"$tn_width\" height=\"$tn_height\" border=\"0\" alt=\"See more details for $title\">"."</a>";
			    
			    $tplv[img] = "<a href=\"item.php?id=".$row[id]."\">"."<IMG SRC=\"$pict_url\" width=\"$tn_width\" height=\"$tn_height\" border=\"0\" alt=\"See more details for $title\">"."</a>";
			    
			    $tplv .= "<a href=\"item.php?id=".$row[id]."\">"."<IMG SRC=\"$pict_url\" width=\"$tn_width\" height=\"$tn_height\" border=\"0\" alt=\"See more details for $title\">"."</a>";
			  }
	  ?>

I think maybe you were telling the script to do things backwards. I have caught myself on this several times. I hope this might help.

Hi Pomona,

Unfortunately that coding made ALL images go to nopicture.gif :icon_rolleyes:

A reply I got to the same post in a phpauction forum came up with a simple solution (which is usually the way) involving one line of code at the beginning of the file to simply disable the error messages:

error_reporting(0);

That fixed it and I also applied it to some other files that are used when clicking on the "More....." links:

view_more_ending.php

view_more_news.php

I appreciate the help you gave and the help of other forums. Without such places as these, us cowboys would have no hope of fixing things. It doesn't matter who solves the problem, it is the fact forums like these exist which is important.

Thanks,

Graham

Yeh I know I'm glad these forums exist too. I'm sorry that I couldn't be of more help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.