Jump to content

Function Help


jasonhardwick

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.