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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.