Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-11-2006, 12:31 PM   #16
Registered: Oct 2003
Location: Tokyo - Japan
Distribution: Slackware
Posts: 348

Original Poster
Blog Entries: 1

Rep: Reputation: 37

Yes, yes, yes!!!
That was, actually, my first thought
But I checked through out the code to find the same as you: nothing.
The comment on the include was a comment I put when I was re-checking for problems on the include files. Nothing.
As you said you confirmed it worked on PHP4, It was working before.

Now I'm taking yours and greamef piece of advice: I'm putting the code back little by little to see where's the problem.
I'll keep you posted.

Originally Posted by Spudley
When you get this error on the last line of your PHP, it usually means that you left something unclosed -- ie mismatched brackets, php tags, or something like that. PHP freaks out because it gets to the end of the program and is expecting more code; it's reporting "unexpected $" because it treats the blank line after the final ?> as a print statement (ie print a carriage return).

As you say, it works in PHP4, and I don't have php5 on my box to test it with. Looking at the code, I can't see anything obviously wrong, but the line <?//include("menu.php");?> makes me wonder if php5 is treating the comment differently, and including the ?> in the comment, in which case, it would definitely cause problems. So maybe try changing that to use /*...*/ comment style instead.

I honestly can't see anything else that would cause problems. Hope you manage to solve it... If all else fails, split it down into bits, and see which one breaks.

All the best.
Old 04-13-2006, 01:26 AM   #17
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, frandalla -

I'm curious - what did you find?

Please keep us posted!

I've never had occasion to use it, but I understand that you can modify your php.ini to do some (fairly verbose) logging. Perhaps that might help?

Last edited by paulsm4; 04-13-2006 at 01:27 AM.
Old 03-15-2007, 01:02 PM   #18
LQ Newbie
Registered: Mar 2007
Posts: 1

Rep: Reputation: 0

Hi all,

Old topic, I know - found it via Google since I had the same problem today. I had the same parse-error - without reason! - I was convinced the code was ok.

After trying some things I found the solution (for me at least). The problem is in the whitespaces. In my case for some reason my file was 'polluted' with windows-spaces (CF). I changed all these into unix spaces (LF) and I got rid of the weird parse-errors from PHP.

To convert spaces unix-style:
- open your file with notepad++ ( (other editors might also be able to do this)
- Go to > format > convert to unix format.
- save and smile (I hope)

That did the tric for me. Hope this reaction might still be usefull for someone.

Note for beginning PHP-programmers: first check all the points mentioned before! It might actually be a PHP parse error caused by a typo.
Old 09-21-2007, 03:11 PM   #19
LQ Newbie
Registered: Sep 2007
Posts: 1

Rep: Reputation: 0
Hi, I just had a struggle with such an issue. I came up with a following solution. It will help to have Linux, or similar scripting environment and commands to use.

I have "index.php" which I run to make an index.html file. It was this file which I had my error. I decided to create the following script so that I could 'target' my bug.


foreach length (50 100 150 200 250 )
  head -n $length index.php > Xindex.php
  echo ---------------------$length-------------------------
  php Xindex.php > xxx
(BTW The length of my file was 225 lines.)

So I ran this script. It essentially breaks up your code and parses the cut up versions of your code. Different lengths of the file are parsed according to the foreach line in the script. I received this output

PHP Parse error:  parse error, unexpected $ in /d/home/coltharp/public_html/ex/page.builder/Xindex.php on line 151
PHP Parse error:  parse error, unexpected $ in /d/home/coltharp/public_html/ex/page.builder/Xindex.php on line 201
PHP Parse error:  parse error, unexpected $ in /d/home/coltharp/public_html/ex/page.builder/Xindex.php on line 224
It just so happened that line 150 was inside a foreach block. So this result did not key me in to my bug. But I continued changing the foreach line in the csh script. Finally I found a place where I had accidentally commented out a closing bracket. Hope this helps!
Old 03-06-2008, 04:10 AM   #20
LQ Newbie
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
I HAVE A PROBLEM WHAT SHOULD I DO, THE PROBLEM IS THIS WHEN I TRY TO OPEN A SITE THEN THIS COME ON SCREEN:Parse error: parse error, unexpected T_STRING in /hsphere/local/home/nohani/ on line 28,WHAT IS THE SOLUTION??

Last edited by hamgerench; 03-06-2008 at 04:11 AM.
Old 03-06-2008, 05:14 AM   #21
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,194

Rep: Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039
"Unexpected $ on line 59" means that there is an unexpected end of file. '$' is used to indicate end of file. It means that usually a closing '}' is forgotten or a ';'

This is one of the obscure error messages of PHP, no matter how powerful PHP is, the error messages are sometimes obscure. (But you get used to it)

Old 03-06-2008, 10:13 AM   #22
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
If it's not your site, you can't do anything (except informing the webmaster)
Else post the code

PS Whole sentences in caps is considered shouting and is usually not appreciated
Old 12-08-2008, 02:37 PM   #23
LQ Newbie
Registered: Dec 2008
Posts: 1

Rep: Reputation: 0
I read this thread about php parser erros and I too have a .php parser error in the PaymentMethod.php file for my cart:

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 133: parser error : Opening and ending tag mismatch: usaepayach line 107 and payach in /home/the/domains/ on line 500

I know that the parsing error exists in the paymentmethod.php file because before I modified the original Adapter Model code, I could access my configuration settings in admin>system>Configuration. Now I have no access to my storeís configuration at all.

I could post the complete .php code but since itís a payment module, I think it would be best to have someone help me fix it by sending him/her the complete code via private message asap.

Please help me fix this so I can access my configuration settings. I know it's a simple fix but I'm new to php.

Thanks you all,
Old 03-04-2009, 12:34 PM   #24
LQ Newbie
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
It's too late, i know ;)

But things like this happend to me all the time.
Just looking at the source, i see a problem (not so obvious may be): I will quote :

$query="select * from user where user_name = '".$_POST['user']."';";
$link = mysql_query($query);
$line = mysql_fetch_array($link);
if((isset($_SESSION['pass']))||($line['user_pass'] == sha1($_POST['pass'])))
{ // ---------- HERE IS ONE OPEN
{ // --------- HERE IS SECOND OPEN
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
} // ---------HERE CLOSES ONE

the rest is ignored.. the script is searching for a command

Sometimes indenting the source helps a lot
three years late, but the true is revealed


error, parser, php, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Parse error" from class_postbit.php loading thread PTrenholme LQ Suggestions & Feedback 2 12-08-2005 11:26 AM
php send email parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expect jamesjoy Programming 7 12-06-2005 04:33 PM
PHP parse error unexpected '>' ldp Programming 2 03-04-2005 02:20 PM
kernel 2.6.0 compliation problems: "parse error before 'va_list'" sohmc Linux - General 6 12-21-2003 04:45 AM
Newbie: "Parse Error" when adding wireless usb network adapter tommer Red Hat 7 10-16-2003 04:48 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:02 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration