Page 1 of 1

variable assignment

Posted: Fri Feb 01, 2008 8:01 pm
by prepster
Hi,

Could somebody help? I'm new to php... programming in general.

I have a variable assiged as

$upload_dir = $uploads_folder_name . "/" . $logged_user_name;

where
$uploads_folder_name = 'files';
$logged_user_name = global variable that grabs the logged in user_name of the session

but when the user logs in as "John", making $logged_user_name = 'John', the script sees $upload_dir as "files/" only. But when I assign $upload_dir = $uploads_folder_name . "/John", then $upload_dir is "files/John".

Are there situations where the session variable is encoded differently or something? I did an ECHO statement of $logged_user_name and it shows as "John" also.

Please help, I've been doing all different combination to get the $upload_dir variable to be properly assigned.

Thanks in advance.

Re: variable assignment

Posted: Sat Feb 02, 2008 5:05 am
by Kieran Huggins
maybe check your spelling... that's a common problem. Also, set your display errors to E_ALL for debugging

Re: variable assignment

Posted: Sat Feb 02, 2008 10:24 am
by andym01480
Don't forget

Code: Select all

session_start();
at the top of every script too!

Re: variable assignment

Posted: Mon Feb 04, 2008 4:20 pm
by prepster
thanks for the replies, but any other suggestions?

when
$uploads_folder_name = 'files';
$logged_user_name = 'John' (acquired as a session variable with a login name of 'John');

the code:
$upload_dir = $uploads_folder_name . "/" . $logged_user_name;

is NOT interpreted as $upload_dir = "files/John" even though it ECHOs as "files/John". When $upload_dir is used for listing the files in the directory, it just shows the contents of "files/", not "files/John/". But if a string is assigned to $logged_user_name, then the string is correctly used in showing the contents of the directory. Why is it that $logged_user_name != 'John' only when passed to the function that uses $upload_dir??

Any ideas anyone?

Re: variable assignment

Posted: Mon Feb 04, 2008 5:42 pm
by Stryks
Just a passing thought (too busy :( ) does it echo 'files/John' or 'files/John/'?

That trailing slash seems as though it could be important.