Need HELP! "$dir"

Discussion in 'PHP' started by Plutonic, Aug 7, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I am doing my first PHP script (Following a tutorial in a book)

    There are errors on certain lines to do with the Directory path, and help?

    These are the errors:

    $dir .= $dir1;
    $dh = opendir($dir);
    Code (markup):
    while ($file = readdir($dh)) :
    Code (markup):
    closedir($dh);
    Code (markup):
    I think I have to make a directory, if so what name?

    I need help!
     
    Plutonic, Aug 7, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    That is the code that is causing the errors. What are the actual error message(s)?

    Are you talking about something like this?:
    if (!is_dir($dir))
        mkdir($dir);
    PHP:
     
    krt, Aug 7, 2007 IP
  3. Plutonic

    Plutonic Peon

    Messages:
    2,964
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It just says something like "can't find dir" or something, any ideas?
     
    Plutonic, Aug 7, 2007 IP
  4. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Are you sure the directory exists?

    Try echo $dir; to confirm the path is correct
     
    krt, Aug 8, 2007 IP
  5. Plutonic

    Plutonic Peon

    Messages:
    2,964
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I created a directory named $dir but I am not sure whether that is what it is meant to be.
     
    Plutonic, Aug 8, 2007 IP
  6. mhuggins

    mhuggins Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    $dir is a variable that should contain a string. You need to find out what value is stored in $dir by echoing it, as was recommended in a prior comment. Simply do this within your code:

    echo $dir;

    Then you can create a folder with the same name as what is stored in this variable.
     
    mhuggins, Aug 8, 2007 IP
Thread Status:
Not open for further replies.