variable assignment

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
prepster
Forum Newbie
Posts: 3
Joined: Fri Feb 01, 2008 7:49 pm

variable assignment

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: variable assignment

Post by Kieran Huggins »

maybe check your spelling... that's a common problem. Also, set your display errors to E_ALL for debugging
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: variable assignment

Post by andym01480 »

Don't forget

Code: Select all

session_start();
at the top of every script too!
prepster
Forum Newbie
Posts: 3
Joined: Fri Feb 01, 2008 7:49 pm

Re: variable assignment

Post 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?
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: variable assignment

Post 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.
Post Reply