...

View Full Version : Problem with php code



Len Whistler
10-12-2003, 08:05 AM
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




<?
$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";
?>

raf
10-12-2003, 10:20 AM
maybe try

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

Len Whistler
10-12-2003, 07:42 PM
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

raf
10-13-2003, 09:36 AM
what is the errorcode ?

firepages
10-13-2003, 04:17 PM
lose the tab (or whitespace) before the closing identifier



HERE; should be ...
HERE;

Len Whistler
10-13-2003, 05:49 PM
Thanks firepages......that was the problem.

Leonard Whistler
www.stubby.ca



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum