0

Error message:

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\index.php on line 135

Code:

if(isset($_REQUEST['d'])
{ // LINE 135 IS THIS ONE
    $d = $_REQUEST['d'];

    if ($d) {
        while (preg_match('/\\\/',$d)) $d = preg_replace('/\\\/','/',$d);
        while (preg_match('/\/\//',$d)) $d = preg_replace('/\/\//','/',$d);
        while (preg_match('/\.\.\//',$d)) $d = preg_replace('/\.\.\//','/',$d);
        if ($d[strlen($d)-1] != '/') $d = $d.'/';
        if ($d == '/') $d = '';
    }
}
2
  • ...on line 135 is usually the most helpful part of any error message.
    – Matt
    Commented Aug 10, 2012 at 20:27
  • Yea I know but I did add the line number in the code.
    – Cocoa Dev
    Commented Aug 11, 2012 at 0:51

2 Answers 2

10

You are missing a closing bracket:

if ( isset($_REQUEST['d'] ) )
1
  • Thanks. I missed the ). Too much looking at PHP code all day causes this
    – Cocoa Dev
    Commented Aug 10, 2012 at 20:22
4

Yan's got the main answer, but you're also missing a backslash in the first regex:

    while (preg_match('/\\\/',$d)) $d = preg_replace('/\\\/','/',$d);
                          ^                              ^

The first two insert a literal backslash into the pattern, while the 3rd backslash is actually escaping the pattern delimiter at the end, leading to an unterminated pattern.

1
  • Thanks for pointing that out! This osFileManager project appears to have so many bugs, issues that need fixing!
    – Cocoa Dev
    Commented Aug 11, 2012 at 0:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.