jasonhardwick Posted May 14, 2008 Share Posted May 14, 2008 ok here is the php i'm having trouble with <?php } } else { //function imageResize(){}; $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); $wh = imageResize($image_t[0], $image_t[1], 100); function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } echo "<img src=\"$img_path\" $wh />"; }?> and here is the error "Fatal error: Call to undefined function: imageresize() in /home/content/j/a/s/jasonhardwick/html/view_topic.php on line 115" line 115 is "$wh = imageResize($image_t[0], $image_t[1], 100);" Link to comment https://forums.phpfreaks.com/topic/105629-function-help/ Share on other sites More sharing options...
jonsjava Posted May 14, 2008 Share Posted May 14, 2008 the error you're getting is for imageresize, not imageResize. in the code I'm seeing, you did it right. Why you're getting that error is beyond me. It should be calling imageResize. Link to comment https://forums.phpfreaks.com/topic/105629-function-help/#findComment-541168 Share on other sites More sharing options...
StormTheGates Posted May 14, 2008 Share Posted May 14, 2008 It looks to me as though your call is above your function declaration. $wh = imageResize($image_t[0], $image_t[1], 100); function imageResize($width, $height, $target) { Maybe put the function above the call? Link to comment https://forums.phpfreaks.com/topic/105629-function-help/#findComment-541230 Share on other sites More sharing options...
thebadbad Posted May 14, 2008 Share Posted May 14, 2008 Yeah, if you use PHP 4, you have to declare a function before you can call it (if my memory is right). In PHP 5 you don't need to, though. Link to comment https://forums.phpfreaks.com/topic/105629-function-help/#findComment-541255 Share on other sites More sharing options...
jasonhardwick Posted May 14, 2008 Author Share Posted May 14, 2008 Ok I tried to move my function. <?php } } else { //function imageResize(){}; $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); function imageResize($width, $height, $target) { $wh = imageResize ($image_t[0], $image_t[1], 100); //function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } echo "<img src=\"$img_path\" $wh />"; }?> but now my image wont resize ??? Link to comment https://forums.phpfreaks.com/topic/105629-function-help/#findComment-541262 Share on other sites More sharing options...
DarkWater Posted May 14, 2008 Share Posted May 14, 2008 You don't move the function header, you move the WHOLE function. *Sigh* function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } $wh = imageResize ($image_t[0], $image_t[1], 100); Link to comment https://forums.phpfreaks.com/topic/105629-function-help/#findComment-541279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.