Jump to content

Unexpected T_ELSE


Daney11

Recommended Posts

<?php if (isset($_POST['submitted'])) {

// Start File Upload
	if (isset($_FILES['upload'])) {

$allowed = array('image/gif');
		if (in_array($_FILES['upload']['type'], $allowed)) {

				if (move_uploaded_file($_FILES['upload']['tmp_name'], "news_images/{$_FILES['upload']['name']}")) {

		echo "Uploaded!";
		}
		else {
		echo 'Not Uploaded!';

		switch ($_FILES['upload']['error']) {
		case 1:
			print 'Files Exceeds.';
			break;
		case 2:
			print 'Max File HTML';
			break;
		case 3:
			print 'No File Uploaded';
			break;
		case 4:
			print 'No Folder';
			break;
		case 6:
			print 'System Error';
			break;
		default:
			print "System Error";
			break;
		}

					} else {
		echo "Wrong Type";
		unlink($_FILES['upload']['tmp_name']);
		}

	} else {
		echo "Smaller Image";
		}
            }
// End File Upload
?>

 

Hey guys, i get this error

 

Parse error: parse error, unexpected T_ELSE in D:\server\www\upload1.php on line 37

 

line 37 being } else {

 

Any ideas?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/91227-unexpected-t_else/
Share on other sites

Such a simple question to ask in the forum.Dont you know that an else should have the corresponding if statement.

I found a missing brace in the code you provided.

Here is the code that I think works:

 

<?php

if (isset($_POST['submitted']))

{

 

// Start File Upload

if (isset($_FILES['upload']))

{

 

$allowed = array('image/gif');

if (in_array($_FILES['upload']['type'], $allowed))

{

 

if (move_uploaded_file($_FILES['upload']['tmp_name'], "news_images/{$_FILES['upload']['name']}"))

{

 

echo "Uploaded!";

}

else

{

echo 'Not Uploaded!';

 

switch ($_FILES['upload']['error'])

{

case 1:

print 'Files Exceeds.';

break;

case 2:

print 'Max File HTML';

break;

case 3:

print 'No File Uploaded';

break;

case 4:

print 'No Folder';

break;

case 6:

print 'System Error';

break;

default:

print "System Error";

break;

 

}

 

}

}

else

{

echo "Wrong Type";

unlink($_FILES['upload']['tmp_name']);

}

 

}

else

{

 

echo "Smaller Image";

}

       

  }

// End File Upload

?>

Link to comment
https://forums.phpfreaks.com/topic/91227-unexpected-t_else/#findComment-467548
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.