georgefisher Posted April 5, 2006 Share Posted April 5, 2006 [!--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 LinuxI 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--] Quote Link to comment https://forums.phpfreaks.com/topic/6675-parse-errors-what-can-i-do/ Share on other sites More sharing options...
TheUkSniper Posted April 5, 2006 Share Posted April 5, 2006 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 :) Quote Link to comment https://forums.phpfreaks.com/topic/6675-parse-errors-what-can-i-do/#findComment-24261 Share on other sites More sharing options...
georgefisher Posted April 5, 2006 Author Share Posted April 5, 2006 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):) :) :) Quote Link to comment https://forums.phpfreaks.com/topic/6675-parse-errors-what-can-i-do/#findComment-24301 Share on other sites More sharing options...
akitchin Posted April 5, 2006 Share Posted April 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6675-parse-errors-what-can-i-do/#findComment-24302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.