PHP mkdir(); Error

Status
Not open for further replies.

cdh47315

New Member
Messages
7
Reaction score
0
Points
0
I'm making a test script for a web application I'm developing, and in the registration of that web app I have a small script in which it makes a few folders under the user's name.
Here is my code:
PHP:
		//If there is not error
		if(!$user->has_error()) {
                        $userdir = "filesystem/".$username;
                        
                        //BEGIN USER FILESYSTEM CREATION
                        mkdir($userdir."/");
                        mkdir($userdir."/home/");
                        mkdir($userdir."/home/media/");
                        mkdir($userdir."/home/scripts/");
                        mkdir($userdir."/home/desktop/");
                        //END USER FILESYSTEM CREATION

			$user->error("Registration successful! You may now log in.");
                }
	}
The line that prints the string "Registration... log in" works just as expected, and I can take out the mkdir() lines and the script will execute perfectly.
With the mkdir() lines, I get this warning message:
Warning: mkdir() [
function.mkdir
]: File exists in /home/cdh473/public_html/<folder>/<folder>/register.php on line 22
And the <folder> directories do have different names...
Anyone know why I'm getting this?
I looked around and saw that x10hosting doesn't use Safe Mode, so that shouldn't be the problem.

EDIT:Also, it should be noted that under the folder "filesystem" it creates a directory called "home" and has all the subdirectories under it that it should, but "home" should be created under the user's own personal folder!
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Let's say $username is "descalzo"

You said "filesystem/descalzo" was not created. But "filesystem/descalzo/home" etc were.
 

cdh47315

New Member
Messages
7
Reaction score
0
Points
0
Let's say $username is "descalzo"

You said "filesystem/descalzo" was not created. But "filesystem/descalzo/home" etc were.

I'll use your example.

$username is "descalzo"
"filesystem/descalzo" is NOT created.
"filesystem/descalzo/home" is NOT created.
"filesystem/home" IS created.

I have no idea why it is happening this way.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Put:

echo "username is: " . $username . " in the script." ;

in your script just before the mkdir.

What it is telling you is that $username is empty.
 
Last edited:

cdh47315

New Member
Messages
7
Reaction score
0
Points
0
Put:

echo "username is: " . $username . " in the script." ;

in your script just before the mkdir.

What it is telling you is that $username is empty.

:rolleyes: I've been trying to figure out the solution all day! How did I not think of this?

EDIT: After a bit of tweaking, I got my script to work. The staff here are fantastic.
 
Last edited:
Status
Not open for further replies.
Top