Function not called?
Posted: Tue Oct 31, 2006 7:57 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
This is a image resizing page. It allows users to upload images and then when images are displayed they are resized into a thumbnail. The function imageResize returns width and height.
"Action2" is called and should then call imageResize further into the function to get the new height and width yet it does not. I downloaded a debugger and have check my syntax and am just not able to figure out why it rolls over the function call ([color=red]no longer highlighted in red below[/color]).
Any help would be very much appreciated.
Thanks.
CharlieCode: Select all
<?
function imageResize($width, $height, $target)
{
echo "IN imageResize";
if ($width > $height)
{
$percentage = ($target / $width);
}
else
{
$percentage = ($target / $height);
}
echo "In Deep";
$width = round($width * $percentage);
$height = round($height * $percentage);
return "width=\"$width\" height=\"$height\"";
}
if($_POST["action2"] == "View Images")
{
$handle = @opendir("Images");
if(!empty($handle))
{
while(false !== ($file = readdir($handle)))
{
if(is_file("Images/" . $file))
{
echo "In View Images";
$mysock = getimagesize("Images/" . $file);
$myMax = 60;
echo $mysock[0];
echo $mysock[1];
echo '<a href="Images/' . $file . '"><img src="Images/' . $file . '" <?php imageResize($mysock[0], $mysock[1], $myMax); ?>></a>';
}
}
}
closedir($handle);
}
if($_POST["action"] == "Upload Image")
{
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
{
$_FILES = $HTTP_POST_FILES;
}
if(!isset($_FILES['image_file']))
{
$error["image_file"] = "An image was not found.";
}
$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;
if(empty($imagename))
{
$error["imagename"] = "The name of the image was not found.";
}
if(empty($error))
{
$newimage = "Images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
chmod("Images/$imagename", 0777);
if(empty($result))
{
$error["result"] = "There was an error moving the uploaded file.";
}
}
}
include("upload_form.php");
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]