Hello, In my cPanel error logs, i see a lt of repeated errors like the one below. I have pasted the makethumb1.php code as well.. can anyone figure out why i'm getting this error message?
error:
Quote:
[Tue Oct 3 20:45:41 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 315
[Tue Oct 3 20:45:41 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 311
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 347
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 345
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagestring(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 343
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 339
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 337
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 335
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagecreate() [<a href='function.imagecreate'>function.imagecreate</a>]: Invalid image dimensions in /home/bad/public_html/car/makethumb1.php on line 333
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 315
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 311
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 347
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 345
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagestring(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 343
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 339
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 337
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 335
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagecreate() [<a href='function.imagecreate'>function.imagecreate</a>]: Invalid image dimensions in /home/bad/public_html/car/makethumb1.php on line 333
Most likely all the errors are being caused by one initial problem.
Examining lines 311 and 315, looking for what would cause the error message given for those lines (Division by zero), we can see that $thumb_x has a zero value.
This is the second parameter in the function -
PHP Code:
function generateThumb($sourceFilename, $thumb_x, $square=FALSE, $border=FALSE) {
This function is only called if the $thumbWidth is greater than zero, so it leaves the lines in the function that modify $thumb_x. The following lines can set $thumb_x to zero, if $image_width is zero -
The function getimagesize(...) can return a FALSE value if the file it is testing is not an image. In this case, $image_width would be null/zero, which is causing the first two error messages. The other error messages are probably (I only traced through the errors to the point of determining the above information) because the file name in $sourceFilename is not an image. The code should test for a FALSE value returned by getimagesize(...) and take appropriate action.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???