Jump to content

[SOLVED] WTF Parse error.


hellonoko

Recommended Posts

My below code is generating this parse error:

 

Parse error: syntax error, unexpected ';', expecting '{' in C:\www\idea\imagebox\add_image.php on line 45

 

Line 45 is:

function copy_image( $file_name );

 

$action = $HTTP_POST_VARS[action];

if ($action == "copy")
{
	function copy_image( $file_name );
}

if ($action == "upload")
{
	function upload_image( $imagefile );
}

 

Functions below. Any dieas?:

Thanks

 

<?php

//upload image function

function upload_image($imagefile,$image_to_thumbnail)
{
ini_set('display_errors', 1);
error_reporting(E_ALL);

//$submit = $_POST['Submit'];
if (empty($_FILES['imagefile']))
	{
		echo "<br><br>";
		echo "Please choose a image to upload...";
		die;
	}


if(!empty( $HTTP_POST_VARS['imagefile'] ))
{

	//If the Submitbutton was pressed do:

	if ($_FILES['imagefile']['type'] == "image/jpeg")
	{

		$_FILES['imagefile']['name'] = str_replace(" ", "_", $_FILES['imagefile']['name']);

		copy ($_FILES['imagefile']['tmp_name'], "images/full/".$_FILES['imagefile']['name']) or die ("Could not copy"); 

		echo "<br><br>"; 
        	
		echo "<b>File Uploaded...</b>"; 
        }

 	else 
 	{
            echo "<br><br>";
            //echo "Could Not Copy... (".$_FILES['imagefile']['name'].")<br>";
		echo "Could Not Copy... <br>";
		die;
     	}
}   

echo "<br>";
$image_to_thumbnail = $_FILES['imagefile']['name'];
//echo $image_to_thumbnail;

include "resize_image.php";

echo "image uploaded";
echo "<br>";
echo "<img src=images/thumbs/t_".$image_to_thumbnail." />";
echo "<br>";
echo "<img src=images/full/".$image_to_thumbnail." />";
}
?> 

<?php

//function to copy image
function copy_image($url, $file_name, $image_to_thumbnail)
{

	$url = $HTTP_POST_VARS[url];
	$file_name = $HTTP_POST_VARS[filename];


	if ($url == "")
	{
		echo "You must enter a url. ";
		echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>";
	}

	if ($file_name == "")
	{
		echo "You must name the file. ";
		echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>";
		exit();
	}

	if ($url != "")
	{
		copy( $url, "images/full/".$file_name );

		$image_to_thumbnail = $file_name;

		include "resize_image.php";

		echo "image coppied";
		echo "<br>";
		echo "<img src=images/thumbs/t_".$image_to_thumbnail." />";
		echo "<br>";
		echo "<img src=images/full/".$image_to_thumbnail." />";

	}
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/82885-solved-wtf-parse-error/
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.