Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-12-2003, 07:05 AM   PM User | #1
Len Whistler
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
Len Whistler is on a distinguished road
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";
?>
Len Whistler is offline   Reply With Quote
Old 10-12-2003, 09:20 AM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
maybe try

print ("<a href=\" . $dirName . "/imageIndex.htm\">images</a>");
raf is offline   Reply With Quote
Old 10-12-2003, 06:42 PM   PM User | #3
Len Whistler
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
Len Whistler is on a distinguished road
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
Len Whistler is offline   Reply With Quote
Old 10-13-2003, 08:36 AM   PM User | #4
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
what is the errorcode ?
raf is offline   Reply With Quote
Old 10-13-2003, 03:17 PM   PM User | #5
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
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)
firepages is offline   Reply With Quote
Old 10-13-2003, 04:49 PM   PM User | #6
Len Whistler
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
Len Whistler is on a distinguished road
Thanks firepages......that was the problem.

Leonard Whistler
www.stubby.ca
Len Whistler is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:41 PM.


Advertisement
Log in to turn off these ads.