Error trying to list images in a directory
| From: | Scott Hamm | Date: | Wed, 20 Oct 2004 12:11:58 +0000 |
| Subject: | Error trying to list images in a directory | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-14555@lists.php.net to get a copy of this message | ||
While trying to learn Php/MySQL from "Php 5/MySQL Programming for the
absolute beginner" book, I copied the exact code and yet ran into error
saying:
"Parse error: syntax error, unexpected $end in C:\Program Files\Apache
Group\Apache2\htdocs\Calendar\Two\test.php on line 41"
Line 41 is a line AFTER </html>
I might be missing something?
<?
$dirName = "C:\Program Files\Apache
Group\Apache2\htdocs\Calendar\Two\Images";
$dp = opendir($dirname);
chdir($dirName);
while($currFile !== false){
$currFile=readDir($dp);
$thefiles[]=$currentfile;
}
$imageFiles=preg_grep("/jpg$|gif$/", $thefiles);
$output = "";
foreach($imagefiles as $currentFile){
$output .= <<<HERE
<a href=$currentfile><img src="$currentfile"></a>
HERE;
}
$fp = fopen("imageindex.html","w");
fputs ($fp, $output);
fclose($fp);
print "<a href=$dirname/imageindex.html></a>\n";
?>