homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Spot the parse error

 4:19 pm on Jun 27, 2012 (gmt 0)

Error is (according to an error_log file):
PHP Parse error: syntax error, unexpected '{' in /process.php on line 1

And the supposedly offending line is in here. These are the first 4 lines in process.php

if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) {
$name = stripslashes(strip_tags($_POST['name']));
} else {$name = 'No name entered';}

Everything makes sense...but yet it has an error...im confused :S



 5:51 pm on Jun 27, 2012 (gmt 0)

A proper IDE will highlight syntax errors in your code and my Netbeans, along with my own eyes tell me there is no parse error here. Are you sure you're in the right file / script?


 6:11 pm on Jun 27, 2012 (gmt 0)

Yep, very sure I'm in the right file. My code editor says there's no un-matched brackets, or open ' or ".

Why is it giving an error? Could there be an error later on in the script? Again, code editor says there's nothing wrong.

I use bluefish for linux with syntax highlighting on.


 6:07 am on Jun 28, 2012 (gmt 0)

I think you may have got one more '(' than ')' in your condition statement, which would throw off the parser when it encounters a '{' without a closing '}' before it finally finds a closing ')'.


 6:38 am on Jun 28, 2012 (gmt 0)






> 0


Definately no mismatch.


 10:47 am on Jun 28, 2012 (gmt 0)

I've given up, and gone another route for what I was doing. Maybe I should submit this to wikipedia under the "additions to the seven wonders of the world"...


 8:36 pm on Jun 28, 2012 (gmt 0)

:: grasping at straws ::

Any chance you've got a wonky server that wants the opening { to be on a new line even though it should make no earthly difference?

:: Vague mental association with Jean "A space is a space" Chrétien ::


 4:25 pm on Jun 29, 2012 (gmt 0)

Although that would likely be a no, it does lead to one possibility - what was it edited in, and how was it uploaded? A scenario might be edited in MS Word and uploaded in binary, or some condition that messes with Unix carriage returns, it can do some odd things with line returns that may muck up the works - the latter is a prevalent problem in perl. If you open it in Notepad and see "black boxes" this could be the problem.

<highly unlikely, but given the seemingly impossible problem with the given example . . . >

You can also change && to the literal 'and' to see if it makes a difference (it shouldn't.)


 8:37 pm on Jul 4, 2012 (gmt 0)

All good suggestions..but no previous problems with the server with similar code.

Code was edited, and made, in a code editor, bluefish (for linux), and uploaded via FireFTP to a linux server.

I've given up and found another solution anyway, but still, gives food for thought for those that have similar problems, or if I come across something like this again.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved