Directory $path syntax problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WPW07

    Directory $path syntax problem

    Hello,

    I have a script that lists the contents of a directory. It was
    working properly until we had to change the directory that it reads
    from.

    The path to this script is:

    /home/n/mu1/database/refresh.php.

    I'd like it to list the contents in the main directory of the site:
    mu1

    So I have this code to list (up one level from the script):

    $path = "../mu1/";
    $dir_handle = opendir($path) or die("Unable to open directory $path");

    But I get this error message when I try to run it:

    Warning: opendir(../mu1/) [function.opendi r]: failed to open dir: No
    such file or directory in /home/n/mu1/database/refresh.php on line 19
    Unable to open directory ../mu1/

    Any idea what I'm doing wrong?

    Thanks!

  • ZeldorBlat

    #2
    Re: Directory $path syntax problem

    On Mar 4, 12:06 pm, WPW07 <wwisnie...@gma il.comwrote:
    Hello,
    >
    I have a script that lists the contents of a directory. It was
    working properly until we had to change the directory that it reads
    from.
    >
    The path to this script is:
    >
    /home/n/mu1/database/refresh.php.
    >
    I'd like it to list the contents in the main directory of the site:
    mu1
    >
    So I have this code to list (up one level from the script):
    >
    $path = "../mu1/";
    $dir_handle = opendir($path) or die("Unable to open directory $path");
    >
    But I get this error message when I try to run it:
    >
    Warning: opendir(../mu1/) [function.opendi r]: failed to open dir: No
    such file or directory in /home/n/mu1/database/refresh.php on line 19
    Unable to open directory ../mu1/
    >
    Any idea what I'm doing wrong?
    >
    Thanks!
    From your location in /home/n/mu1/database/refresh.php the value
    of ../ would be the directory above /database which is /mu1. So, "../
    mu1" is really /home/n/mu1/mu1/ which probably isn't what you want.
    If you're inside /database you get to mu1 with ../ by itself.

    Comment

    • WPW07

      #3
      Re: Directory $path syntax problem

      On Mar 4, 12:45 pm, ZeldorBlat <zeldorb...@gma il.comwrote:
      On Mar 4, 12:06 pm, WPW07 <wwisnie...@gma il.comwrote:
      >
      >
      >
      Hello,
      >
      I have a script that lists the contents of a directory. It was
      working properly until we had to change the directory that it reads
      from.
      >
      The path to this script is:
      >
      /home/n/mu1/database/refresh.php.
      >
      I'd like it to list the contents in the main directory of the site:
      mu1
      >
      So I have this code to list (up one level from the script):
      >
      $path = "../mu1/";
      $dir_handle = opendir($path) or die("Unable to open directory $path");
      >
      But I get this error message when I try to run it:
      >
      Warning: opendir(../mu1/) [function.opendi r]: failed to open dir: No
      such file or directory in /home/n/mu1/database/refresh.php on line 19
      Unable to open directory ../mu1/
      >
      Any idea what I'm doing wrong?
      >
      Thanks!
      >
      From your location in /home/n/mu1/database/refresh.php the value
      of ../ would be the directory above /database which is /mu1. So, "../
      mu1" is really /home/n/mu1/mu1/ which probably isn't what you want.
      If you're inside /database you get to mu1 with ../ by itself.

      Thank you. That fixed it!

      Comment

      Working...