Jump to content

Php Documents Generating 500 Server Error


Recommended Posts

I am curious why, after a certain amount of time, the server (stevie) seems to unload PHP from memory, resulting in all requests for a PHP document generating 500 errors for a short while. My site has low traffic, but many of my pages use PHP, and so when a visitor does come along, the see 500 errors, which could lead them to think that my site is dysfunctional.

Link to comment
Share on other sites

the server (stevie) seems to unload PHP from memory

 

Generally speaking when you get a 500 error the opposite is the case, when the server encounters a user's site reaching beyond the user's process limits it'll start to serve 500 errors. Check your code to make sure that you didn't accidentally set up an infinite loop or that you left pages without ?> tags.

Link to comment
Share on other sites

I am careful to avoid infinite loops on my site, since that would obviously cause problems. As for pages without ?>, I intentionally do that for the pages that are purely for PHP code to prevent accidental output of extra whitespace. I was wondering why it was happening because my site goes from effectively no traffic to some traffic, but I get 500 error from only the PHP scripts, regardless of complexity or location (even `<?php echo "It Works!"; ?>` would fail). Without any modification, they work a small amount of time later (about a mintute or two)

Link to comment
Share on other sites

but I get 500 error from only the PHP scripts, regardless of complexity or location (even `<?php echo "It Works!"; ?>` would fail). Without any modification, they work a small amount of time later (about a mintute or two)

 

Yeah, as long as the unclosed pages are opened they keep the PHP interpreter loaded in memory until the system realizes it's just wasting that space and kills it. So after a slight delay eventually you do start seeing the expected PHP output, but while extraneous instances are running your site will serve 500 errors.

Link to comment
Share on other sites

actually no, there's no need to put ?> in your php, many frameworks/cms don't put one, and php interpreter is not kept in memory

server passes the file to php, php parses until eof and returns output, it doesn't sit in the background waiting for closing tag

 

my guess the reason you sometimes get 500 error is too many requests to the server

Link to comment
Share on other sites

The same thing happens to me. I am using a forum on my site (phpbb), and even it produces errors..... I don't think many people visit my site at all. In fact, only me and like 2 other people...

Link to comment
Share on other sites

I finally managed to get this error while testing a text editor running through a textarea. In my case I originally had the script output through the textarea's value attribute which ended up a little broken. When i simplified it to

<textarea cols="80" rows="25" id="TEXT">
<?php if(isset($_POST['open'])){
if(isset($_POST['file'])){
echo file_get_contents($_POST['file']);
}
} ?>
</textarea>

I had left out the closing php tag and after opening a couple files, got the error. I waited a couple minutes, went into the source and put the missing tag and haven't gotten the error again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...