PHP Warrings:

partymaker

New Member
Messages
7
Reaction score
0
Points
0
Can someone tell me what this means:


I try resize the image.
Script doing that corectly , but on the page appears this:

"Division by zero in file....... in line 187"
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Means you did a devision by 0... I'm guessing we'll need your code to help you :p
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
your guessing? lol. unless you have my 133t h4x0rzing skillz, we are gonna need the file. lawl.

yeah, so anyways: Division by zero is considered an error in ANY language, as it creates the instance of an infinate loop.
 

konekt

New Member
Messages
100
Reaction score
0
Points
0
divide-by-zero.jpg





Sorry about that, couldn't resist :)

As stated, we need to see where in your code you attempted to destroy the fabric of the cosmos.
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
0
Points
0
Actually, all we need is the code on like 187 unless there is(are) a variable(s) involved; if so, we need to see where and how you set that(those) variable(s).
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Actually, all we need is the code on like 187 unless there is(are) a variable(s) involved; if so, we need to see where and how you set that(those) variable(s).

He changed the image's size... Unless he set the width variable to 0 (which should be really stupid) it's most likely a combination of mathematic operations that give the 0 that has been used to devide. Just give us everything, because we probally will have to ask for more anyway...
 

partymaker

New Member
Messages
7
Reaction score
0
Points
0
$w11- original weight
$h11- original height

$w1- new weight (desired);

First I set $w1 and I have to calculate new $h1

$h1- new height

code is:
$row=getimagesize("images.jpg");
$w11=$row[0];
$h11=$row[1];
$k1=($w11/$h11);
$h1=($w1/$k1);
Edit:
line 187 $k1=($w11/$h11);
line 188 $h1=($w1/$k1);
Edit:
Of course I didn't set w1=0
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
$w11- original weight
$h11- original height

$w1- new weight (desired);

First I set $w1 and I have to calculate new $h1

$h1- new height

code is:
$row=getimagesize("images.jpg");
$w11=$row[0];
$h11=$row[1];
$k1=($w11/$h11);
$h1=($w1/$k1);
Edit:
line 187 $k1=($w11/$h11);
line 188 $h1=($w1/$k1);
Edit:
Of course I didn't set w1=0

$row[1] is probally 0, where does it come from?
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
getimagesize() returns an array where index 0 is the width and index 1 is the height. My guess would be that the image you specified doesn't exist, so false is returned. Which means that both the height and width are being set to null and then cast as 0 when you divide them.

Make sure the image you specified does exist. If it exists in a different directory from the script, you need to specify that as part of the file name parameter. Such as, getimagesize('images/images.jpg');
 

TechAsh

Retired
Messages
5,853
Reaction score
7
Points
38
A good idea would be to check that the variable isn't 0 before trying to to the division. Something like:
PHP:
$row=getimagesize("images.jpg");
$w11=$row[0];
$h11=$row[1];

if ($w11 == 0 || $h11 == 0) {
die("Error: One of more variables is zero.");
}
else { 
$k1=($w11/$h11);
$h1=($w1/$k1);
}
In this case it'll output a nicer error if one of the variables is zero. However that doesn't solve your problem.
 
Top