Results 1 to 4 of 4

Thread: need syntax for $dir_handle = @opendir

  1. #1
    Join Date
    Feb 2010
    Posts
    27
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default need syntax for $dir_handle = @opendir

    Need a quick jumpstart,

    I have this,

    $dir_handle = @opendir($thumb_directory) or die . . .

    but my files don't link with this

    $thumb_directory = 'C:/Documents and Settings/. . . /thumb/';

    where is the typo, I know it's simple, but this is my first attempt with php.

    thanks in advance!

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    resource opendir ( string $path [, resource $context ] )

    Opens up a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls.
    PHP Code:
    <?php
    $dir 
    "/etc/php5/";

    // Open a known directory, and proceed to read its contents
    if (is_dir($dir)) {
        if (
    $dh opendir($dir)) {
            while ((
    $file readdir($dh)) !== false) {
                echo 
    "filename: $file : filetype: " filetype($dir $file) . "\n";
            }
            
    closedir($dh);
        }
    }
    ?>
    For example...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Feb 2010
    Posts
    27
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default thanks!

    i have all that, and it works fine, i just didn't copy it to the thread.

    the problem, unless I am wrong is in the setup:

    $thumb_directory = 'C:/Documents and Settings/dontworryaboutit/ . . . /thumb/';

    as I am getting an error message "cannot find files"

    so I am thinking that there is a typo is the file path.

    what say ye o wise one?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You should be using a relative path, not an absolute path.

    Just change that to '../dir/whatever/thumbs/" and it should work.

    For more information, view the page on "readdir" at PHP.net because that shows several examples of the standard format.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •