For Programmers: Free Programming Magazines  


Home > Archive > PHP Installation > October 2004 > Error trying to list images in a directory









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Error trying to list images in a directory
Scott Hamm

2004-10-20, 8:56 am

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

?>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com