Welcome to WebmasterWorld Guest from 54.161.96.239

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Spot the parse error

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

Preferred Member

5+ Year Member

joined:Dec 10, 2007
posts: 507
votes: 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


<?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 June 27, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts: 394
votes: 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 June 27, 2012 (gmt 0)

Preferred Member

5+ Year Member

joined:Dec 10, 2007
posts: 507
votes: 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 June 28, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
posts:940
votes: 27


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 June 28, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


(

(isset
($_POST['name'])
)

&&

(strlen

(trim
($_POST['name'])
)

> 0
)

)

Definately no mismatch.
10:47 am on June 28, 2012 (gmt 0)

Preferred Member

5+ Year Member

joined:Dec 10, 2007
posts: 507
votes: 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 June 28, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13834
votes: 484


:: 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 June 29, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 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 July 4, 2012 (gmt 0)

Preferred Member

5+ Year Member

joined:Dec 10, 2007
posts: 507
votes: 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.

:)
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members