SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help for simple error

    I so confuse and don't know why this code doesn't work

    PHP Code:
    <html>
    <head></head>
    <body>
    <?
    chdir
    ('c:/inetpub/wwwroot/myfol/');
    $dir='galleries/asiatour/hongkong';
    $catlistgetcat($dir);

    reset($catlist);
    $catcount count($catlist);


    for(
    $i=1;$i<=$catcount;$i++)
    {
        echo 
    '<b>'.$catlist[$i].'</b><br>';
    }

    echo 
    'end';

    function 
    getcat($name)
    {
        
    $categorylist=array();
        
    chdir($name);
        if (!(
    $handle opendir($name))) 
        { 
            echo 
    'Error !';
        } else
        {
            while(
    $entry readdir($handle)) {
                if (
    is_dir($entry) && $entry != ".") {
                    
    $categorylist[] = $entry;
                }
            }
        }
     return 
    $categorylist;
    }
    ?>
    </body>
    </html>
    it would return the name of all sub-folders of the given path don't know why I always get the error :

    "Warning: OpenDir: Invalid argument (errno 22) in c:\inetpub\wwwroot\myfol\list.php on line 28"

    thanks in advance.

  2. #2
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you are first going into

    c:/inetpub/wwwroot/myfol/

    than you go to this folder:

    galleries/asiatour/hongkong (with chdir($name); )

    so by the time you do*opendir($name) being opendir(galleries/asiatour/hongkong) in this case, you are already in

    c:/inetpub/wwwroot/myfol/galleries/asiatour/hongkong

    so with opendir(galleries/asiatour/hongkong) you are actually opening a directory

    c:/inetpub/wwwroot/myfol/galleries/asiatour/hongkonggalleries/asiatour/hongkong

    wich of course doesn't exist and results in an error

    just drop chdir($name); and it should work (at least if the folder really exists)
    PHP-Webservices - Profesional Hosting and Programming of sites.

  3. #3
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks

    but after changed it I have had another error with is_dir stat dont know why with that exact code , some file manager scripst I found work

    I have 4 folders name : 1 , 2 , 3 , 4 in there and this's the error :
    Code:
    Warning: stat failed for 1 (errno=2 - No such file or directory) in c:\inetpub\wwwroot\myfol\list.php on line 34
    
    Warning: stat failed for 4 (errno=2 - No such file or directory) in c:\inetpub\wwwroot\myfol\list.php on line 34
    
    Warning: stat failed for 3 (errno=2 - No such file or directory) in c:\inetpub\wwwroot\myfol\list.php on line 34
    
    Warning: stat failed for 2 (errno=2 - No such file or directory) in c:\inetpub\wwwroot\myfol\list.php on line 34
    end
    thank you again

  4. #4
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    does php have authorization to view those directories?
    PHP-Webservices - Profesional Hosting and Programming of sites.

  5. #5
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes , it on my own PC and there is no restriction

  6. #6
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then you have a problem

    I can't seem to think of a solution with the info I have, sorry
    PHP-Webservices - Profesional Hosting and Programming of sites.

  7. #7
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it already get the name of all folders but show the warning that's so strange .

    By the way thanks so much

  8. #8
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP-Webservices - Profesional Hosting and Programming of sites.


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
  •