please help meWarning: mkdir() [function.mkdir]: File exists in..xxxxx/register.php. yeah yeah what is wrong here is my code:
btw im at xxxxx/register.php

$documentroot = $_SERVER['DOCUMENT_ROOT'];
if(mkdir($documentroot ."/". $username , 0777))
$profile = $documentroot ."/". $username ."/index.php" ;
$filegettingcopy = $documentroot ."/xxxxx/index.php" ;
if (copy($filegettingcopy, $profile))
{echo "<br> You can access your profile at <a href=\"http://www.mysite.com/" . $username. "\">www.mysite.com/$username</a> <br>";
   echo "There was a problem. Your profile was not made. ";

those few lines of code are supposed to make the directory of the username of the person who registering chooses....
AND copy the index.php file from the directory xxxxx into the new "username" directory.
im getting the error and obviously there was a problem.. your profile was not made. what am i doing incorectly?

Edited by SKANK!!!!!: n/a

8 Years
Discussion Span
Last Post by SKANK!!!!!


As the Warning says, the file or directory you are trying to create appears to already exist.
Have you verified that this is not the case?

You should use the file_exists function on your path before trying to create it, to make sure it actually needs to/can be created.

Check out Indenting!

Edited by Atli: n/a


You can't create a directory that already exists.
If I were you, I would add another if clause the checks if the directory exists.
If it does, it can do nothing or delete its contents, if it doesn't create it.

For instance,

$dir = $docroot . '/' . $username;
if (!file_exists ( $dir )) {

thank you thank you thank you. for 1 i didnt know it had actually made the directory all ready and for two... i didnt know that meant that it had. and also. thank u for the directory check. it works!!!!!!!!!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.