0

first time posting here.

So here it goes: I came across a very strange error and after wasting a lot of time debugging the file I found out, to my surprise, that what was causing the error were some comment lines with //.

In my .php file there was something like this:

<table>
      <tr>
        <td>
            <?php 
            //se porto alegre
            if($cd_empr == 1){ ?>
                <a href="../home/index.php">Home</a> &gt;<a href="../porto_poa/porto_poa_apresentacao.php"> Porto de Porto Alegre</a> &gt; Operadores 
            <?php 
            //se pelotas
            }else if($cd_empr == 2){ ?>
                <a href="../home/index.php">Home</a> &gt;<a href="../porto_pel/porto_pel_apresentacao.php"> Porto de Pelotas</a> &gt; Operadores 
            <?php } ?>
        </td>
    </tr>
</table>

This was causing the page to just go blank and on FireBug the only error message I get is "NetworkError: 500 Internal Server Error".

When I erase those // comment lines or replace them with /* comment */, the error is gone.

Does this have anything to do with the server's PHP Version (which is 5.3.3)? I'm asking this because I have many other files like this that are running OK on a local machine, but when I tried running them on a remote hosting server I stumbled with this problem.

Thanks in advance and sorry for the dumb question.

Edit: updated with the actual code as asked.

Maurício
  • 11
  • 4
  • 7
    http://stackoverflow.com/a/185803/508666 – PeeHaa Oct 07 '13 at 18:55
  • Have checked the error log to see what the specific error is? – kunal Oct 07 '13 at 18:57
  • [Heredoc](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) – Kermit Oct 07 '13 at 18:57
  • 1
    Only thing I see is that you are using a php short tag on the closing brace `} ?>`. Try using ``. Also try checking the web server error logs. 500 errors do get logged. – Jonathan Kuhn Oct 07 '13 at 18:58
  • 2
    "Code something like this" is not useful in this situation. If you want an *actual* answer we will need to see the *actual* code causing the error. – Sammitch Oct 07 '13 at 19:03
  • Updated the code with the actual code right now.I believe the server isn't saving error logs(I checked the phpinfo and there is no value on log_error) – Maurício Oct 07 '13 at 19:12
  • You might want to set a value for `log_error` then, so that you can actually see what the 500 error is. – ajp15243 Oct 07 '13 at 19:31
  • I don't have access to the php.ini file. – Maurício Oct 07 '13 at 19:36
  • Perhaps ask for assistance from the person who does control it then? – ajp15243 Oct 07 '13 at 20:12
  • I did, but since it is a shared hosting service if the logs are enabled I would have access to errors of other applications running on the server too... – Maurício Oct 08 '13 at 12:26

1 Answers1

0

Maybe you're experiencing these problems because of this line:

<?} ?>

It can cause your problem if if short open tags are disabled in your php.ini. Try to replace this line with:

<?php } ?> 

and let me know what'll happen.

Sam Braslavskiy
  • 1,268
  • 10
  • 19
  • Thanks for answering. I tried it but the error persists and I am sure that the short open tags are enabled. – Maurício Oct 07 '13 at 19:07
  • I've tried your code on my server. It works just as it meant to. Everything is quite all right, so you'd rather look at another part of your code. E.g. where you're defining $cd_empr or whatever.. – Sam Braslavskiy Oct 07 '13 at 19:19
  • Before posting here I have already tried setting $cd_empr to a fixed value just for testing purposes and nothing changed. I also commented parts of the code and in the end I found that the problem only goes away when I remove those comment lines or use the other comment syntax. – Maurício Oct 07 '13 at 19:23
  • well, there's also PHP 5.3 on my server... Is your problem consistent? Maybe it was just a coincidence...like problems of the hosting provider or sth. like that?.. because i strongly believe that comments can't cause such an issue. – Sam Braslavskiy Oct 07 '13 at 19:32
  • I have no other clue of what is causing it, but everytime I delete those lines it works. What is even weirder is that I can use comment lines with // on the first lines of the file(where the includes are) with no problem. – Maurício Oct 07 '13 at 19:42