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.
variable assignment
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: variable assignment
maybe check your spelling... that's a common problem. Also, set your display errors to E_ALL for debugging
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: variable assignment
Don't forget at the top of every script too!
Code: Select all
session_start();Re: variable assignment
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?
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
Just a passing thought (too busy
) does it echo 'files/John' or 'files/John/'?
That trailing slash seems as though it could be important.
That trailing slash seems as though it could be important.