user1542296
user1542296

Reputation: 735

Inconsistent Fatal error: Maximum execution time of 30 seconds exceeded

I have a php form where a user showed me that they received a fatal error:

Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache2.2\htdocs\eeallparts\registration.php on line 282.  

What is odd is that they resubmitted the form again and the form worked as it is supposed to inserted the data into the database so this isn't a consistent error. I get quite a few submissions on the form (a fair degree of them spam) so I know that the form usually works, but this random error bothers me obviously.

I went to the line 282 and the only thing I see is this:

if(!$insertContact_query = mssql_query($sql)) {     

I read a couple of the other threads related to this that suggested to look at the set time limit. If the query simply takes too long wouldn't the query virtually always time out instead of periodically time out? I had the user resubmit the same information in the form and it worked the second time?

Upvotes: 0

Views: 678

Answers (1)

NathanD
NathanD

Reputation: 380

The time limit doesn't include time spent on any external data sources like time it takes to query the database.

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

If the query returns large dataset it may timeout simply during processing the set. If possible use php profile to indicate bottlenecks.

Upvotes: 1

Related Questions