Hi everyone, i have been looking around your forum and had some usefull information in the past.

I have now had to join up now and ask for some wise help if possible,

Basically i am getting a parse error on some of my php files but not all the time, if i refresh the page after getting the error it works fine??

It always reports the error as been the end line of the file.

I can post the code from one of the files if needed but as the file is working fine 95% of the time i thought i would find out if anyone had similar problems/ fixes in the past. I already tried google and found nothing relevent.

Thanks all

Carl

    there are error messages, and warnings. May be in your server's enviroment might be just warnings.
    Write the messages down, and that line where this happened.

    bye,jjozsi.

    cwjackso;10889902 wrote:

    Hi everyone, i have been looking around your forum and had some usefull information in the past.

    I have now had to join up now and ask for some wise help if possible,

    Basically i am getting a parse error on some of my php files but not all the time, if i refresh the page after getting the error it works fine??

    It always reports the error as been the end line of the file.

    I can post the code from one of the files if needed but as the file is working fine 95% of the time i thought i would find out if anyone had similar problems/ fixes in the past. I already tried google and found nothing relevent.

    Thanks all

    Carl

      Just managed to get one to come up....

      Parse error: parse error in /u2/WWW/htdocs/cpd/cpd2/update/bulk_update.php on line 365

      it reallty does take a while sometimes you keep having to press refresh to get the error (obviously it comes up first click sometimes.

      Anyway, line 365 is the last line of that file, and the script stops executing with nothing else displayed.

      Carl

        if there is no data in that line, lets check the character coding of tha page, and check if your editor takes special characters at the end of file. i often see that is hexa editor to find strange characters.
        on other servers you should check.

        hello

        cwjackso;10889905 wrote:

        Just managed to get one to come up....

        it reallty does take a while sometimes you keep having to press refresh to get the error (obviously it comes up first click sometimes.

        Anyway, line 365 is the last line of that file, and the script stops executing with nothing else displayed.

        Carl

          I cant see anything wrong with that line.

          If it wasn't working most of the time i'd be looking through my code for missed closing braces etc with the line number been the end of the file (already done this anyway and its fine).

          I just can't understand why it throws up the error every now and then but the rest of the time it works perfect.

          Carl

            djjjozsi is suggesting that there might be hidden data on that line which you should check with a hex editor.

              Fair point i'll check.

              If there was though, surely the parse error would show every time the file was loaded?

              Carl

                Ok there was no problems when checking with an hex editor but i have Manged to fix it. The problem was with Short PHP Tags:

                For some reason a part of the code with short tags was been ignored by the server and just output as text causing a brace to be missing from the code.

                eg:

                <?php 
                start a loop here{
                some more php code;
                ?>
                
                Some Lines of HTML code 
                ........
                ........
                <? } end loop here ?>
                

                the closing brace is ignored 'occassionaly' for some reason causing the parse error.

                after doing a find replace (<? with <?php) everything is fine.
                Anyone seen or heard of this before?

                Thanks for your help
                Carl

                  No, but then I do not use short open tags to begin with since they are not guaranteed to be enabled and may conflict with <?xml open tags.

                    For short tags to lurch between "on" and "off" ... the only sane reason that comes to my mind right now is that there is more than one server handling the load and they're configured differently.

                    That's just a guess on my part - I've always got them turned off, myself.

                      Maybe,

                      I dont manage the servers so not really sure.

                      I Know they can clash with xml tags from what i've looked into since having this error but again would presume that to be a consistant problem

                      From now on I'll not be using them anyway!

                      Thanks again

                      Carl

                        Write a Reply...