Results 1 to 4 of 4

Thread: Error mkdir() in PHP

  1. #1
    Join Date
    Nov 2009
    Posts
    518

    Error mkdir() in PHP

    Hi
    I am trying an php code and getting an error constantly. Warning mkdir(); [function.mkdir]: The file exists in /home/......./verify.php. I am getting that error constantly that is the problem. i am posting my code below. I do not think there is a problem with php code. Still you guys check it and please help.
    Code:
    mkdir('$name',0777);
     $name = ucfirst(strtolower($_POST['username-reg']));
    Any advice or suggestion on this. Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Error mkdir() in PHP

    Hi
    I think the directory is already existing there this is why it is giving you an error. You have even made some mistakes in you code. The following should be in quote
    Code:
    $name
    Else it will create the directory $name and not the value that $name refers to.
    One more thing is that , you need to define the $name before you try to create a directory otherwise the value will be empty. check the following part of the code.
    Code:
    $name = ucfirst(strtolower($_POST['username-reg']));
    if (is_dir($name)) { mkdir($name, 0777); }
    If any more query do post back.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Error mkdir() in PHP

    Hi
    the above mentioned points are absolutely correct. You make the changes to your code and it will run for you. I have some other options for you. You may also use
    Code:
    uscword()
    instead of
    Code:
    ucfirst()
    This will be implemented if the $name will include the first and the last name or otherwise only the first name will be capitalized. Try this option, these are very handy options some times. If you have solved the problem then do post back with the updated / modified code.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Error mkdir() in PHP

    Hello
    I would like to mention one more point that is on some server configurations you will have to make the default directory at the setting of 644 and then you can change the mode to 777, if you want to use that. My suggestion to you is to try 755 first because it is safer than what you are trying. Some hands on programs will give you this experience. So, enjoy coding and any problem do post.

Similar Threads

  1. Replies: 6
    Last Post: 12-11-2010, 11:37 PM
  2. Implementation of mkdir() : C
    By Agustíne in forum Software Development
    Replies: 4
    Last Post: 02-02-2010, 06:16 PM
  3. Mkdir with variable space
    By Kingfisher in forum Software Development
    Replies: 5
    Last Post: 19-12-2009, 11:55 AM
  4. mkdir with date
    By tom.henricksen@gmail.com in forum Windows Server Help
    Replies: 4
    Last Post: 17-03-2007, 12:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,556,409.57087 seconds with 17 queries