Hi everyone -

Am getting the following error:
Parse error: syntax error, unexpected T_STRING in ... /index.php on line 11

Where the php file that's doing the reading of the directory is the index.php page in that directory.

Line 11 is the 'while loop' below. What I'm not understanding is that there are no quotes and no missing semicolons just before or on line 11. There just isn't that much.

Here's the code:

<?php
// name this file index.php and include it inside the directory you want the list from

// open the current directory
$dhandle = opendir('.');
// define an array to hold the files
$files = array();

if ($dhandle) {
** // loop through all of the files
** while (false !== ($fname = readdir($dhandle))) {
***** // if the file is not this file, and does not start with a '.' or '..',
***** // then store it for later display
***** if (($fname != '.') && ($fname != '..') &&
********* ($fname != basename($_SERVER['PHP_SELF']))) {
********* // store the filename
********* $files[] = (is_dir( "./$fname" )) ? "(Dir) {$fname}" : $fname;
******}
** }
** // close the directory
** closedir($dhandle);
}


// Now loop through the files, with a new line after each one
foreach( $files as $fname )
{
** echo "$fname \n";
}

?>

Any help would be gratefully appreciated. Thanks!

Lee

    Have never seen asterisks appear where the spaces are before in code on this forum. Anyone know what that's about? Could there be something about the way the spaces are made that is causing this error?

      What text editor are you using? If it's some sort of word processor, are you saving the file as plain ASCII text?

        Hiya, thanks for replying...

        I'm using Textwrangler, son of BBEdit.

        I'll see if fixing these makes a difference. They don't show up at all on the page.

        Thanks!

        Lee

          Yep - replacing the invisible asterisks made it work. Don't get a line return, though, but I think I can figure that one out.

          Thanks!

            4 days later

            <?php
            $output = shell_exec('ls -asl directory');
            echo "<pre>$output</pre>";
            ?>

              Write a Reply...