1

I'm not looking to change maximum execution time at this time, (like every thread in the search box,) I just want to error handle the line, but it's not working for me.

Here's my code:

$multiSupplierResult    = mysqli_query($con, $multiSupplierQuery) or trigger_error("Query Failed! SQL: $multiSupplierResult");

I get this error though when I run the query with too many lines:

Fatal error: Maximum execution time of 30 seconds exceeded in blah blah on line blah blah....

Why is my error handler not working?

Update

I found this code in the other thread, which works great:

register_shutdown_function('shutdownFunction');

function shutDownFunction() { 
    $error = error_get_last();
    if ($error['type'] == 1) {
        echo "<pre>";
        print "blah blah blah";
        echo "</pre>";     
    } 
}

However, if the user searches too many parts, and the query takes more than 30 seconds, they see this blah blah blah message, but they ALSO still see the Fatal Error message. How do I HIDE that message completely?

Brian Powell
  • 3,336
  • 4
  • 34
  • 60

2 Answers2

2

Fatal error is an exception.

Your line of code uses a binary comparison and therefore gets skipped.

For any normal exception you would need a try {} catch() {} block to catch exceptions.

Fatal Error unfortunately is a special case. More information here

Community
  • 1
  • 1
scones
  • 3,317
  • 23
  • 34
  • @JohnWu As mentioned in the comment of the other answer, the main problem is a 30 second excution time of the query. You should either optimize that, which requires a different question, or you should increase the maximum execution time. – scones Feb 04 '15 at 15:53
0

The error handling isn't working because it's not the query that is causing the error. It simply took to long to execute the command and retrieve results. You can change the maximum execution time to allow more time for the command to finish.

You can use this: ini_set('max_execution_time', numberInSeconds);.

Aleksandar B.
  • 128
  • 1
  • 9
  • This is the reason this FatalError pops up. The error handling is not working, because of the fatal error. I agree on principle, that the reason should be fixed. My guess is, that the query needs to be optimized to run in under 30 seconds. – scones Feb 04 '15 at 15:45
  • Yeah... from my original post, `I'm not looking to change maximum execution time....` If they stress the system too much, I want to tell them to search for fewer items. – Brian Powell Feb 04 '15 at 15:45