Jump to content

Archived

This topic is now archived and is closed to further replies.

georgefisher

Parse Errors - what can I do?

Recommended Posts

[!--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:
[b]Parse error: parse error, unexpected $ in /var/www/petvets/petvets-www/contest/admin.php on line 2910[/b]

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 -
[b]* 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?
[/b]

[!--sizec--][/span][!--/sizec--]

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
The end of the code is this:
[code]function formatForPost( $string)
{
    $bad = array("\"", ">", "<");
    $good  = array(""", ">", "<");

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

?>
[/code]
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)

:) :) :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.