If Else troubles

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

If Else troubles

Post by mhouldridge »

Hi,

What seems a simple if else statement is not working. It is as follows;

Code: Select all

if (file_exists($userfile_name)) {
	echo "Error - The $userfile (name) already exists.  Please change the name of this file to something else and try again.";
	} 
else (move_uploaded_file($userfile, $add)) {
	echo "File uploaded, thankyou";
	}
Please help.
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

anyone???
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

I have sorted this now, however my first check file exist statement does not work,

Any ideas?

Here is the script.

Code: Select all

if (file_exists($userfile_name)) {
	echo "Error - Filename already exists.  Please change the name of this file to something else and try again.";
	} 
else {
	(move_uploaded_file($userfile, $add));
	echo "File uploaded, thankyou";
	}
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

$userfile_name and $userfile should both be the same variable, I believe...
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

sorted it now.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Remove the parenthesis from this line

(move_uploaded_file($userfile, $add))

to

move_uploaded_file($userfile, $add)
Post Reply