LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-11-2006, 01:31 PM   #16
frandalla
Member
 
Registered: Oct 2003
Location: Tokyo - Japan
Distribution: Slackware
Posts: 348
Blog Entries: 1

Original Poster
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.

Quote:
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, 02:26 AM   #17
paulsm4
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!

PS:
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?

http://us3.php.net/errorfunc

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

Rep: Reputation: 0
Lightbulb

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++ (notepad-plus.sourceforge.net) (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, 04:11 PM   #19
PhilipColtharp
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.

Code:
#!/bin/csh

foreach length (50 100 150 200 250 )
  head -n $length index.php > Xindex.php
  echo ---------------------$length-------------------------
  php Xindex.php > xxx
end
(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

Code:
---------------------50-------------------------
---------------------100-------------------------
---------------------150-------------------------
PHP Parse error:  parse error, unexpected $ in /d/home/coltharp/public_html/ex/page.builder/Xindex.php on line 151
---------------------200-------------------------
PHP Parse error:  parse error, unexpected $ in /d/home/coltharp/public_html/ex/page.builder/Xindex.php on line 201
---------------------250-------------------------
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, 05:10 AM   #20
hamgerench
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/baask.com/diwan/Settings.php on line 28,WHAT IS THE SOLUTION??

Last edited by hamgerench; 03-06-2008 at 05:11 AM.
 
Old 03-06-2008, 06:14 AM   #21
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,235

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
"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)

jlinkels
 
Old 03-06-2008, 11: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
@hamgerench:
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, 03:37 PM   #23
befree22
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/silverborn.com/public_html/lib/Varien/Simplexml/Config.php 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,
Leslie
 
Old 03-04-2009, 01:34 PM   #24
jcalcagno
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 :

<?php
session_start();
include("file.php");
$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
if(!isset($_SESSION['pass']))
{ // --------- HERE IS SECOND OPEN
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
} // ---------HERE CLOSES ONE
?> // HERE THE SCRIPTS END, WITH UNBALANCED PARENTHESIS

the rest is ignored.. the script is searching for a command
<html>
<head>
..
..
..

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


Reply

Tags
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 12:26 PM
php send email parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expect jamesjoy Programming 7 12-06-2005 05:33 PM
PHP parse error unexpected '>' ldp Programming 2 03-04-2005 03:20 PM
kernel 2.6.0 compliation problems: "parse error before 'va_list'" sohmc Linux - General 6 12-21-2003 05:45 AM
Newbie: "Parse Error" when adding wireless usb network adapter tommer Red Hat 7 10-16-2003 05:48 PM


All times are GMT -5. The time now is 07:07 PM.

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