?
Solved

PHP parse error

Posted on 2005-03-23
2
Medium Priority
?
185 Views
Last Modified: 2006-11-17
I get the following error in the script below, I can't figure out what's wrong.
Can anyone tell me?
Note: comments have been removed and line numbers don't match but the offending line has a lot of ***********, the curly bracket was all there was on that line

[client 192.168.1.13] PHP Parse error:  parse error, unexpected '{' in /home/meeting/chair/display_tree.php on line 31, referer: http://192.168.1.13/select_files.php

<? session_start(); ?>
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head><title>Select files</title>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
</head>
<body background='wp2c.png'>
<table class='tabl01'><tr><td width='100%'>
<h2>Directories and files</h2>
<?
if ( isset($_POST['submit']) && $_POST['submit'] == 'Working files have been selected.' ) {
  echo '<pre>';
  print_r($_POST['files']);
  echo '</pre>';
  $files=($_POST['files']);
  $_SESSION['files'] = $files;
  echo "<form action='makeit_rw.php'><input type='submit' name='submit1' value='Selection is     correct'></form>";
}
$dirs[0] = 'test';            # adjust for real life
$files=array();
while ( $dirs ) {
  $dir = opendir(reset($dirs));
  while ( ($file = readdir($dir)#) !== false )
    { //this is line 31 ********************************************
    if ( $file != '.' && $file !== '..' ) {
      if ( is_dir(current($dirs).'/'.$file) ) {
        $dirs[] = current($dirs).'/'.$file;
      } else
      {
        $files[] = current($dirs).'/'.$file;
      }
    }
  }
 $_SESSION['dirs'] = $dirs;
 closedir($dir);
 unset($dirs[key($dirs)]);
}
sort ($files);
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
foreach ( $files as $file )
{
  echo '<input type="checkbox" name="files[]" value="', $file, '">', $file, '<br/>';
}
?>
<input type="submit" name="submit" value="Working files have been selected.">
</form></td></tr></table></body></html>
0
Comment
Question by:rblampain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 11

Accepted Solution

by:
matt_mcswain earned 2000 total points
ID: 13619450
# is also a comment
Remove it from your while loop
So:

 while ( ($file = readdir($dir)) !== false )
    { //this is line 31 **
0
 
LVL 11

Expert Comment

by:matt_mcswain
ID: 13619491
BTW, this is good reason why I prefer to use an editor that understands php and color codes it.
Catching misplaced comments, inproperly terminated strings, mispelling of php functions, etc. become obvious because the code changes color for different elements. Dreamweaver's pretty good, Zend Studio is surely the best b/c it displays syntax errors similarly to the way Word Processors do. So most parse errors are caught before you ever execute your script.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question