Jump to content


Parse Errors - what can I do?

  • Please log in to reply
3 replies to this topic

#1 georgefisher

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 April 2006 - 07:25 PM

[!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--]Hello everyone, this may be a really obvious problem, but I am at my wits end and I decided to post somewhere.
I have been encountering a problem with a PHP script I have written.

Whenever I run the script on a particular web server I get the error message:
Parse error: parse error, unexpected $ in /var/www/petvets/petvets-www/contest/admin.php on line 2910

2910 is the last line of my code.

I have:
* removed whitespace from the right hand side of blocks of text and made sure they are all at the start of lines (i.e. echo<<<TEXT...TEXT;)
* converted to unix linebreaks
* uploaded in binary
* code is tabbed correctly, no missing { and }
* runs on Windows (versions 5.1.2 and 4.3.2) and Linux (4.3.0)

My code is very long and it is not possible to post it here.

The problem occurs on PHP version 4.2.2 on Linux

I suppose my questions are -
* Do you know what could cause this parse error?
* Is there a PHP parser with more descriptive errors?
* Should I tell the webhost to upgrade their PHP - is this a common error with version 4.2.2?


#2 TheUkSniper

  • Members
  • PipPip
  • Member
  • 23 posts

Posted 05 April 2006 - 07:31 PM

you make it practically unpossible to help you if we cant see your code... copy just a few lines from the end rather than the whole code if thats the part where the problem is :)

#3 georgefisher

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 April 2006 - 10:10 PM

The end of the code is this:
function formatForPost( $string)
    $bad = array("\"", ">", "<");
    $good  = array(""", ">", "<");

    return str_replace($bad, $good, $string);

but, for more clarity, I have posted the entirety of the code here:
[a href=\"http://www.esoce.com/work/admin.txt\" target=\"_blank\"]http://www.esoce.com/work/admin.txt[/a]

My question is mostly - is this a case where the problem is the hosting company running an old version of PHP? If so, I can use a third opinion to back up the case for upgrading.

Alternatively the problem could be system specific. I was wondering if the problem sounded familiar? Any ideas upon how could it be fixed?
I have got PHP to print out it's configuration here: [a href=\"http://www.petvets.com/contest/info.php\" target=\"_blank\"]http://www.petvets.com/contest/info.php[/a] (this is the system the script does not run on)

:) :) :)

#4 akitchin

  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 05 April 2006 - 10:17 PM

generally speaking, these errors come when you have missed a closing brace in some statement somewhere. since the parser is not expecting an end to the script (given that a braced statement is still open somewhere), it spits out a parse error.

time to play the brace game. check EVERY statement you open. a syntax highlighter may come in handy here, since any colour aberration after a certain point in the script is a clear indicator that you've forgotten to close a brace.

hope this helps.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users