I get random Parse error: syntax error, unexpected $end in my code. All i have to do is refresh the page and the error goes away, all is working. When it appears the line is always different and when i examine the line nothing is wrong with the code. This is frustrating because i don't know how to debug it.... It's random.

Has anyone ever experienced this before. For example i got this error randomly..

Parse error: syntax error, unexpected $end in ... on line 3828

$searchterm1 = substr($searchterm, 0, $limitz1) . '..';

believe me there is nothing wrong with that line. When i refresh the error dissapears until a randomly get another parse error $end with a different line.

Any help appreciated.

Recommended Answers

Unexpected end usually means that somewhere a semi-colon or a closing curly bracket is missing.

Jump to Post

Use an editor with syntax highlighting, or an IDE.

Jump to Post

All 6 Replies

Unexpected end usually means that somewhere a semi-colon or a closing curly bracket is missing.

have any recommendations on how i would debug over 3000 lines of code for that missing semicolon or curly bracket?

see you are getting error in line 3828 and that too parse error so it seems that you missed semicolon on the previous line or the curly bracket .Just check the curly bracket and semi-colon.although it is hard to find in a code of 3000 lines....you can use netbeans editor that will just help you to do it in much better way...

Member Avatar

3000 lines of code?? What on earth?
If your code is properly indented, you should be able to check for braces. Notepad++ allows you to collapse sections (braces) so *should* be easy. If it's a semicolon, '3828' will be close to the offending line.

do any of the database columns, if any used, or any other imported data include characters that when parsed could trick the parser into displaying this error
if an unsanitized data field included a ';' it may cause such an error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.