Okay, I'm sorry for the length of this post, but I've worked my way thru a
number of exercises--acoupla chapters' worth, in fact, since that last
question was solved--before being stumped again. I'm not just turning pages
and running to you folks without doing any work of my own. I'm trying to
cut out excess code, but I again apologize that this is longish nonetheless.

Again, I am on a Macintosh PowerBook, where my hard drive is, in fact,
named a variation of "My Hard Drive" (with cap letters and spaces, as the
Macintosh allows). So this brings me to my first questions:

Do I change the line $dirName = "c:/csci/mm" to something like $dirName =
My Hard Drive:/ followed by the exact name of every last folder until I
come to the folder containing the GIFs and JPEGs I want to index and follow
that with the .html extension? Or do I use something like $dirName =
http://localhost/[my username]/ followed by  the exact name of every last
folder until I come to the folder containing the GIFs and JPEGs I want to
index and follow that with the .html extension?

The error message refers to "unexpected $ ... on line 33". Line 33 of the
code below is: </a>.

Then, of course,  the "unexpected $" of the error message does refer to the
variable names to use in the $_POST--or is it better to use $_REQUEST
instead?--lines right after <?php. Which of these belongs and why? Or,
actually, which doesn't, and how come?

$imageIndex = $_POST['imageIndex']?
$dirName = $_POST['dirName'];
$currentFile = $_POST['currentFile'];
$theFiles = $_POST['theFiles'];
$imageFiles = $_POST['imageFiles'];
$output = $_POST['output'];

Am I on the right track, at least?

Thank you very much.

Steve Tiano
----------------------------------------------------------------------------
-----

The code:

<?php
// image index
// generates an index file containing all images in a particular directory

//point to whatever directory you wish to index.
//index will be written to this directory as imageIndex.html
$dirName = "c:/csci/mm";
$dp = opendir($dirName);
chdir($dirName);

//add all files in directory to $theFiles array
while ($currentFile !== false){
  $currentFile = readDir($dp);
  $theFiles[] = $currentFile;
} // end while

//extract gif and jpg images
$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;

} // end foreach

//save the index to the local file system
$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
//readFile("imageIndex.html");
print "<a href = $dirName/imageIndex.html>image index</a>\n";

 ?>

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to