rc726c Posted January 4, 2009 Share Posted January 4, 2009 could someone tell me "why am i takeing these error codes?" ---- first error code is about include function: [Wed Dec 10 01:06:14 2008] [error] [client 88.xxx.xxx.216] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '../admin/conn.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/w/htdocs/online/duckula/ustbilgi.php on line 32 my include code is: include_once("../admin/conn.inc"); (adress is correct,mysql connection is working) (there is connection codes(username,password etc) in conn.inc) ---- the second error code is about imagedestroy function: [Wed Dec 10 02:58:05 2008] [error] [client 195.xxx.xx.32] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /var/www/html/w/htdocs/online/duckula/fotolar/thumb.php on line 47, referer: http://www.site.com/ and this is the tumb.php: <? /* =================================== + yThumb Class + Author: Yunus Emre Yilmaz + http://yns.zaxaz.com/ythumb.yns =================================== */ class yThumb { // find extension of file function find_extension($file) { $array = explode('.',$file); $key = count($array) -1; $ext = $array[$key]; return $ext; } function thumb($image,$w,$h) { if($this->find_extension($image) == 'jpg') $image_data = imagecreatefromjpeg($image); if($this->find_extension($image) == 'gif') $image_data = imagecreatefromgif ($image); if($this->find_extension($image) == 'png') $image_data = imagecreatefrompng ($image); // Original width && height $width = imagesx($image_data); $height = imagesy($image_data); // Control width && and height if(@$w > 800 || @$h > 800) { $w= $width; $h= $height; } if(@empty($w)) $w = 400; if(@empty($h)) $h = 600; $new = imagecreatetruecolor($w, $h); imagecopyresampled($new, $image_data, 0, 0, 0, 0, $w, $h, $width, $height); // Finally, output.. if($this->find_extension($image) == 'jpg') $image_data = imagejpeg($new); if($this->find_extension($image) == 'gif') $image_data = imagegif ($new); if($this->find_extension($image) == 'png') $image_data = imagepng ($new); // Flush memory imagedestroy($image_data); // line 47 imagedestroy($new); } } $a = new yThumb(); $a->thumb($_GET["image"],@$_GET["w"],@$_GET["h"]); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/ Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 As for the second error, change / Finally, output.. if($this->find_extension($image) == 'jpg') $image_data = imagejpeg($new); if($this->find_extension($image) == 'gif') $image_data = imagegif ($new); if($this->find_extension($image) == 'png') $image_data = imagepng ($new); to: $data = pathinfo($image); switch(strtolower($data['extension'])) { case 'gif': $image_data = imagegif($new); break; case 'png': $image_data = imagepng($new); break; case 'jpg': default: $image_data = imagejpeg($new); break; } if(isset($image_data)) { imagedestroy($image_data); imagedestroy($new); } else { die('Error processing thumbnail'); } For you first error. PHP will convert the following path ../admin/conn.inc to /var/www/html/w/htdocs/online/admin/conn.inc is this the correct path? Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/#findComment-729316 Share on other sites More sharing options...
rc726c Posted January 4, 2009 Author Share Posted January 4, 2009 for first problem.. yes; the path is true.. should i include like this: include_once("/var/www/html/w/htdocs/online/admin/conn.inc "); Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/#findComment-729318 Share on other sites More sharing options...
rc726c Posted January 4, 2009 Author Share Posted January 4, 2009 and for second problem, i did like this: is this alright? <? /* =================================== + yThumb Class + Author: Yunus Emre Yilmaz + http://yns.zaxaz.com/ythumb.yns =================================== */ class yThumb { // find extension of file function find_extension($file) { $array = explode('.',$file); $key = count($array) -1; $ext = $array[$key]; return $ext; } function thumb($image,$w,$h) { if($this->find_extension($image) == 'jpg') $image_data = imagecreatefromjpeg($image); if($this->find_extension($image) == 'gif') $image_data = imagecreatefromgif ($image); if($this->find_extension($image) == 'png') $image_data = imagecreatefrompng ($image); // Original width && height $width = imagesx($image_data); $height = imagesy($image_data); // Control width && and height if(@$w > 800 || @$h > 800) { $w= $width; $h= $height; } if(@empty($w)) $w = 400; if(@empty($h)) $h = 600; $new = imagecreatetruecolor($w, $h); imagecopyresampled($new, $image_data, 0, 0, 0, 0, $w, $h, $width, $height); // Finally, output.. $data = pathinfo($image); switch(strtolower($data['extension'])) { case 'gif': $image_data = imagegif($new); break; case 'png': $image_data = imagepng($new); break; case 'jpg': default: $image_data = imagejpeg($new); break; } if(isset($image_data)) { imagedestroy($image_data); imagedestroy($new); } else { die('Error processing thumbnail'); } // Flush memory imagedestroy($image_data); imagedestroy($new); } } $a = new yThumb(); $a->thumb($_GET["image"],@$_GET["w"],@$_GET["h"]); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/#findComment-729319 Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 should i include like this: include_once("/var/www/html/w/htdocs/online/admin/conn.inc "); No, I was just confirming whether /var/www/html/w/htdocs/online/admin/conn.inc Is the correct full path to the file you're trying to include? If so your relative path should work. However you could use include_once($_SERBER['DOCUMENT_ROOT']."/admin/conn.inc"); Also note, using .inc is insecure as your PHP code will displayed as plain text. You should use the following name convention instead filename.inc.php this will prevent your source code from being displayed and improve security. and for second problem, i did like this: is this alright? <? /* =================================== + yThumb Class + Author: Yunus Emre Yilmaz + http://yns.zaxaz.com/ythumb.yns =================================== */ class yThumb { // find extension of file function find_extension($file) { $array = explode('.',$file); $key = count($array) -1; $ext = $array[$key]; return $ext; } function thumb($image,$w,$h) { if($this->find_extension($image) == 'jpg') $image_data = imagecreatefromjpeg($image); if($this->find_extension($image) == 'gif') $image_data = imagecreatefromgif ($image); if($this->find_extension($image) == 'png') $image_data = imagecreatefrompng ($image); // Original width && height $width = imagesx($image_data); $height = imagesy($image_data); // Control width && and height if(@$w > 800 || @$h > 800) { $w= $width; $h= $height; } if(@empty($w)) $w = 400; if(@empty($h)) $h = 600; $new = imagecreatetruecolor($w, $h); imagecopyresampled($new, $image_data, 0, 0, 0, 0, $w, $h, $width, $height); // Finally, output.. $data = pathinfo($image); switch(strtolower($data['extension'])) { case 'gif': $image_data = imagegif($new); break; case 'png': $image_data = imagepng($new); break; case 'jpg': default: $image_data = imagejpeg($new); break; } if(isset($image_data)) { imagedestroy($image_data); imagedestroy($new); } else { die('Error processing thumbnail'); } // Flush memory imagedestroy($image_data); imagedestroy($new); } } $a = new yThumb(); $a->thumb($_GET["image"],@$_GET["w"],@$_GET["h"]); ?> Remove // Flush memory imagedestroy($image_data); imagedestroy($new); } Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/#findComment-729321 Share on other sites More sharing options...
rc726c Posted January 4, 2009 Author Share Posted January 4, 2009 ok i understand... thank u so much.. but this code is not working? could u try it on your own computer? <? /* =================================== + yThumb Class + Author: Yunus Emre Yilmaz + http://yns.zaxaz.com/ythumb.yns =================================== */ class yThumb { // find extension of file function find_extension($file) { $array = explode('.',$file); $key = count($array) -1; $ext = $array[$key]; return $ext; } function thumb($image,$w,$h) { if($this->find_extension($image) == 'jpg') $image_data = imagecreatefromjpeg($image); if($this->find_extension($image) == 'gif') $image_data = imagecreatefromgif ($image); if($this->find_extension($image) == 'png') $image_data = imagecreatefrompng ($image); // Original width && height $width = imagesx($image_data); $height = imagesy($image_data); // Control width && and height if(@$w > 800 || @$h > 800) { $w= $width; $h= $height; } if(@empty($w)) $w = 400; if(@empty($h)) $h = 600; $new = imagecreatetruecolor($w, $h); imagecopyresampled($new, $image_data, 0, 0, 0, 0, $w, $h, $width, $height); // Finally, output.. $data = pathinfo($image); switch(strtolower($data['extension'])) { case 'gif': $image_data = imagegif($new); break; case 'png': $image_data = imagepng($new); break; case 'jpg': default: $image_data = imagejpeg($new); break; } if(isset($image_data)) { imagedestroy($image_data); imagedestroy($new); } else { die('Error processing thumbnail'); } } $a = new yThumb(); $a->thumb($_GET["image"],@$_GET["w"],@$_GET["h"]); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/#findComment-729323 Share on other sites More sharing options...
rc726c Posted January 4, 2009 Author Share Posted January 4, 2009 could someone help me to fix the second problem(image destroy)?? Quote Link to comment https://forums.phpfreaks.com/topic/139421-error-logs/#findComment-729393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.