Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts

    Problem with php code

    Below is a php code I copied from a book at the store. It should take all the .JPGs and .GIFs in a folder and create thumbnails. You then click the thumbnails for a larger picture. But I get a error message for line 27, which is the last line with ?>

    I can't figure it out. Thanks

    Leonard Whistler
    www.stubby.ca



    PHP Code:
    <?
        $dirName 
    "images";
        
    $dp opendir ($dirName);
        
    chdir ($dirName);

        while (
    $currentFile !== false) {
        
    $currentFile readDir ($dp);
        
    $theFiles [ ] = $currentFile;
    }
        
    $imageFiles preg_grep (" /jpg$ | gif$ / "$theFiles);
        
    $output " ";

        foreach (
    $imageFiles as $currentFile) {
            
    $output .= <<<HERE

        <a href = $currentFile>
        <img src = "$currentFile" height = 50 width = 50></a>
        HERE;
    }
        
        $fp = fopen ("imageIndex.htm" , "w");
        fputs ($fp, $output);
        fclose ($fp);

        print "<a href = $dirName/imageIndex.htm>images</a>\n";
    ?>

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe try

    print ("<a href=\" . $dirName . "/imageIndex.htm\">images</a>");

  • #3
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Thanks Raf.....But it still doesn't work. I don't understand why the error message is for the last line, when the mistake is on another line.

    I might just buy the book with the CD. I think their is a typo in the book.

    Leonard Whistler
    www.stubby.ca

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what is the errorcode ?

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,051
    Thanks
    10
    Thanked 94 Times in 92 Posts
    lose the tab (or whitespace) before the closing identifier

    Code:
        HERE; should be ...
    HERE;
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #6
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Thanks firepages......that was the problem.

    Leonard Whistler
    www.stubby.ca


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •