php variable wrong- which do i correct

Quack

Registered Member
Joined
Sep 9, 2009
Messages
62
Reaction score
20
Hi,
using a amazon store script, receiving this warning,

"Warning
: Division by zero in /public_html/ireland/widget_featured.php on line 19"

the warning reffers to this line: 1st line is 19,then 20 etc

$percent = 80 / $height;
$percentw = 80 / $width;
if( $percentw < $percent ) $percent = $percentw;
if( $percent > 1 ) $percent = 1;
$width = (integer) ($percent * $width);
$height = (integer) ($percent * $height);


I understand that there may be a misspelling,just no idea what:confused:
thanks in advance
 
Last edited:
it appears that $height takes the value of 0 so i would give it a value

something like

PHP:
if($height==0 || $height=='') $height=1;

just before line 19 :)
 
Last edited:
thanks for the help,

I,ve added the above like so

$item = $parsed_xml->Items->Item;
$imgURL = $item->MediumImage->URL;
$width = $item->MediumImage->Width;
$height = $item->MediumImage->Height;
if($height==0 || $height=='') $height=1;
$percent = 80 / $height;
$percentw = 80 / $width;
if( $percentw < $percent ) $percent = $percentw;
if( $percent > 1 ) $percent = 1;
$width = (integer) ($percent * $width);
$height = (integer) ($percent * $height);

without much luck,
 
Maybe try to insert this line just before line 19:

if (!isset($height)) {$height=1}
 
adding the code provided my lord, has removed the line 19 error, great start

I should have added that I had the same error for both line 19 and 20

so I only have the same issue with line 20
I, thinking that I just add the same line again changing height to width
 
thanks lord, worked great ...this php looks fun, me thinks I want to learn this :)

Again Thanks
 
Back
Top