Re: Error trying to list images in a directory
| From: | Janet Valade | Date: | Wed, 20 Oct 2004 17:10:31 +0000 |
| Subject: | Re: Error trying to list images in a directory | ||
| References: | 1 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-14558@lists.php.net to get a copy of this message | ||
Scott Hamm wrote:
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"; ?>If you mean that line 41 is a line number after your program ends, this usually means that something is not closed. That is, a missing } or ) or perhaps an opening " with no closing ". Sometimes it's using a } when it should be a ) or a ) that should be a }. Check out your heredoc. The first HERE must have nothing after it on the line, not even a blank space. The second HERE must begin at the very beginning of the line, with nothing before it, not even a blank space. Janet -- Janet Valade -- janet.valade.com