update_image.php

if($image_width > $data2['maxwidth'] or $image_height > $data2['maxheight'])
                    {
                    echo '<br>'."Image is too big".'<br>';
                    echo $image_width.'>'.$data2['maxwidth_bn'].'<br>';
                    echo $image_height.'>'.$data2['maxheight_bn'];
                    exit();
                    }



Successfully upload pictures
Image is too big
995>1000
229>240             

I wonder why the condition pass? It suppose to be too small instead of too big.

Recommended Answers

All 5 Replies

You're outputting two different values than the ones you're checking for.
Your if loop looks at maxwidth and maxheight but your message outputs maxwidth_btn and maxheight_btn.
So from that you can't actually be sure that the height/width fails the condition. Unless you know that maxwidth and maxwidth_btn are definitely the same value?
I'm pretty sure if you output maxwidth and maxheight one of those will be passing the IF condition.

if($image_width > $data2['maxwidth'] or $image_height > $data2['maxheight'])

shouldn't this be like

if($image_width > $data2['maxwidth'] || $image_height > $data2['maxheight'])

As hericles said, you are using 2 different variables in comparison $data2['maxwidth'] v. $data2['maxwidth_bn'] and $data2['maxheight'] v. $data2['maxheight_bn']. There is no way to check whether both your variables are the same as its counter part.

if($image_width > $data3['maxwidth_bn'] || $image_height > $data3['maxheight_bn'])
                    {
                    echo "Image is too big";
                    echo $image_width.'>'.$data3['maxwidth_bn'];
                    echo $image_height.'>'.$data3['maxheight_bn'];
                    exit();
                    }   

I still do not understand why it pass the condition:

Image is too big
597>1000
424>240

if($image_width > $data3['maxwidth_bn'] || $image_height > $data3['maxheight_bn'])

That means:
IF the image width is larger than max_width OR the image height is larger than max_height, the image is too big.

Is it too wide? 597 is not larger than 1000, so no.
Is it too high? 424 is larger than 240, so yes.

If either one is true (OR) it will be too big.

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.