Page 1 of 1

PHP error on error.php :-)

Posted: Wed Mar 25, 2009 3:18 pm
by Gonecat
Hello,

I'm a project manager trying to help a client while my PHP guy is away today. Oye!

(I do have some Coldfusion background, heh heh)



Anyway, the site is not coming up (white page) and the host has said the following:

Fatal error: Maximum execution time of 30 seconds exceeded in
/vservers/angelisms/htdocs/includes/error.php on line 4

It appears there is something wrong with the function in the error.php file.



The error.php file has the following:

Code: Select all

 
<?php
set_error_handler('errorHandler');
 
function errorHandler ($errno, $errstr, $errfile, $errline, $errcontext)
{
    switch ($errno)
    {
        case E_USER_WARNING:
        case E_USER_NOTICE:
        case E_WARNING:
        case E_NOTICE:
        case E_CORE_WARNING:
        case E_COMPILE_WARNING:
            break;
        case E_USER_ERROR:
        case E_ERROR:
        case E_PARSE:
        case E_CORE_ERROR:
        case E_COMPILE_ERROR:               
       
            //@session_start();
             
            if (eregi('^(sql)$', $errstr)) {
                $MYSQL_ERRNO = mysql_errno();
                $MYSQL_ERROR = mysql_error();
                $errstr = "MySQL error: $MYSQL_ERRNO : $MYSQL_ERROR";           
            } // if
             
            echo "<h2>An error occurred.</h2>\n";
            echo "<b><font color='red'>\n";
            echo "<p>Fatal Error: $errstr (# $errno).</p>\n";           
            echo "<p>Error in line $errline of file '$errfile'.</p>\n";
            echo "<p>Script&#058; '{$_SERVER['PHP_SELF']}'.</p>\n";
            echo "</b></font>";
             
            // Stop the system
            //session_unset();
            //session_destroy();
            die();
        default:
            break;
   } // switch
} // errorHandler
?>
 

Any help would be greatly appreciated...!

Re: PHP error on error.php :-)

Posted: Thu Mar 26, 2009 12:17 am
by sujithtomy
Hello,

you can increase execution time limit by setting via set_time_limit() function.

set_time_limit — Limits the maximum execution time

Description
void set_time_limit ( int $seconds )

Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.