syntax Q for using _SESSION[XXXX] variable in a dir variable line

I create a file folder (dir) on the server for the session user logged in by inserting $_SESSION[MM_Username] as shown below. The folder (dir) is created. I use the exact same $_SESSION[MM_Username] in the variable $uploaddir below that, but the file doesn’t make it into the new folder created just above. I"v tried single quotes like ‘$_SESSION[MM_Username]’ and $_SESSION turns blue as it should, but its [MM_Username] stays black and the script fails as well.

Any help would be much appreciated. Thank you

[php]<?php
mkdir("/wamp/www/DIGITALDATABASE/$_SESSION[MM_Username]", 0700);
?>

<?php $uploaddir = '/wamp/www/DIGITALDATABASE/$_SESSION[MM_Username]/}'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); ?>[/php]

The bracket “}” at the end was a typo and it’s not in the line (1). The line is correctly shown at the bottom (2).

[php]
(1) $uploaddir = ‘/wamp/www/DIGITALDATABASE/$_SESSION[MM_Username]/}’;

(2) $uploaddir = ‘/wamp/www/DIGITALDATABASE/$_SESSION[MM_Username]/’;
[/php]

Got this to work. I don’t understand it all, but I used the mkdir operation on a previous page instead of just above the $uploaddir variable setting and BAM, works!

Sponsor our Newsletter | Privacy Policy | Terms of Service