0

I have a php sript with a simple mysql SELECT query which fetches more than 1000 rows from the database...

It gives a 500 internal server error many times when I have a large number of rows to fetch..

The same script works fine when I run it from unix shell command:

/usr/bin/php  scriptname.php

It's a server with apache + php fcgi.

Please help -- thanks!

3
  • 1
    Have a look at your apache error log. It will contain more information about the problem. Update your question with what you find.
    – user9517
    Jan 13, 2011 at 11:59
  • How is PHP configured? CGI/FastCGI/mod_php?
    – Reece45
    Jan 13, 2011 at 14:22
  • php configured with fastcgi ... Jan 13, 2011 at 20:28

4 Answers 4

0

I think you're probably hitting the Fcgi timeout. How long does the script take to run? What does Apache's error_log say? Have you tried changing the FcgidBusyTimeout Directive in the Apache config?

1
  • Glad I could help!
    – Josh
    Jan 15, 2011 at 15:39
0

Probably your script exceeds timeout limit. You should use set_time_limit function.

1
  • 1
    I don't think so, if limit is reached, error is printed if allowed, but it never returned 500 - Internal server error to me, seems like apache issue.
    – Ency
    Jan 13, 2011 at 14:09
0

How about changing your script, just returning a part of the rows (e.g. 1st 100 rows) and then giving the possibility to fetch the next ones.

Not every problem can be fixed with some configuration parameters.

0

This can be due to several issues, PHP has different controls to avoid an script to go crazy (max memory and max execution time).

The 3 most common problems associated with a 50x error from your server are

  • Script has timeouted its maximum execution time : You'll see this one because it'll take a long time to reply, one way to avoid this is to override the max execution time in the first line of the script if you know that it'll actually take more than the default max execution
  • Script has used all the available memory : This one will be a lot quicker and possibly it'll be your one, it can be also overriden in case your script needs it
  • Infinite recursive loop : This will be quite violent, and it's the last scenario, normally it's either of the first two, so if neither solution works it's a likely scenario

Good luck with your debugging!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .