Results 1 to 23 of 23

Thread: Fatal error Maximum execution time of 30 seconds exceeded

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Fatal error Maximum execution time of 30 seconds exceeded

    Hi,

    I wonder why I get this error on my localhost machine.

    Fatal error Maximum execution time of 30 seconds exceeded

    php.ini is 30 secs by default but when I do my login page and login, it will load for very long and give this error, I wonder whats went wrong? Is it my next page php file too big.

    Thanks in advanced

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    yes, that's the jist of it. either your next page is too big, or you probably have a continuous loop that keeps loading things when you shouldn't.

    post your code. for the "next page."
    Like Archer? Check out some Sterling Archer quotes.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    A login page should never, ever take 30 seconds. You must have an infinite loop or similar programming error in there.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Thanks for the reply Actually my next page got around 1000 lines of coding, is it part of the problem as my next page is just convert from a html file to php and starting got around 100 lines of php codings for restriction base on session.

    If thats the main course, can I have all the php coding then follow by a php coding or javascript that display a newly create html files for the content?

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    1000 lines is nothing. Except a good place for a bug to hide.

    Other than that, I have no clue what you said.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Thanks for your reply if 1000 lines isn't the main problem, is there any program can spot error on my files and fix it if possible?

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    I haven't heard of a PHP linter, but perhaps there is one.

    Other than that, there's only yourself. Write out messages during page processing and call flush() to make sure they're immediately sent to the client. This way, you can narrow down where it gets stuck.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    New Member
    Join Date
    Oct 2006
    Posts
    4

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Look at the line number. Fatal error. Dies on that line which caused the infinity.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Thanks But I don't quite understand the flush thingy, I don't know where should I put. I think I will show my coding better.

    PHP Code:
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      
    session_start();
    }

    // ** Logout the current user. **
    $logoutAction $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset(
    $_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      
    $logoutAction .="&"htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      
    //to fully log out a visitor we need to clear the session varialbles
      
    $_SESSION['MM_Username'] = NULL;
      
    $_SESSION['MM_UserGroup'] = NULL;
      
    $_SESSION['PrevUrl'] = NULL;
      unset(
    $_SESSION['MM_Username']);
      unset(
    $_SESSION['MM_UserGroup']);
      unset(
    $_SESSION['PrevUrl']);
        
      
    $logoutGoTo "index.html";
      if (
    $logoutGoTo) {
        
    header("Location: $logoutGoTo");
        exit;
      }
    }
    ?>
    <?php
    if (!isset($_SESSION)) {
      
    session_start();
    }
    $MM_authorizedUsers "";
    $MM_donotCheckaccess "true";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
      
    // For security, start by assuming the visitor is NOT authorized. 
      
    $isValid False

      
    // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
      // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
      
    if (!empty($UserName)) { 
        
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
        // Parse the strings into arrays. 
        
    $arrUsers Explode(","$strUsers); 
        
    $arrGroups Explode(","$strGroups); 
        if (
    in_array($UserName$arrUsers)) { 
          
    $isValid true
        } 
        
    // Or, you may restrict access to only certain users based on their username. 
        
    if (in_array($UserGroup$arrGroups)) { 
          
    $isValid true
        } 
        if ((
    $strUsers == "") && true) { 
          
    $isValid true
        } 
      } 
      return 
    $isValid
    }

    $MM_restrictGoTo "login.php";
    if (!((isset(
    $_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
      
    $MM_qsChar "?";
      
    $MM_referrer $_SERVER['PHP_SELF'];
      if (
    strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
      if (isset(
    $QUERY_STRING) && strlen($QUERY_STRING) > 0
      
    $MM_referrer .= "?" $QUERY_STRING;
      
    $MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
      
    header("Location: "$MM_restrictGoTo); 
      exit;
    }
    ?>
    <?php 
    echo $logoutAction ?>
    Then below all is all those lots HTML coding.

    If people go to the above restrict page, my website will redirect as http://localhost/Web/login.php?acces...protected1.php
    then after it redirect to login.php, when user login, it will load very slow and show the fatal error msg.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Quote Originally Posted by klutz
    Look at the line number. Fatal error. Dies on that line which caused the infinity.
    Thanks for your first post to me My line 5 is } as I have post my php codes above.

  11. #11
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    well, you should be posting the source to the page that loads slow, (or at least -some- of that page, because I for one am not going to skim through 1000 lines of code), not the page before it.
    Like Archer? Check out some Sterling Archer quotes.

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Just use session_destroy() rather than manually unsetting all the variables (and setting them to null first, which is redundant).

    I cannot understand why a login page would exceed 30 seconds execution. You must have a loop or some external call. Neither of which should be necessary.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Quote Originally Posted by kows
    well, you should be posting the source to the page that loads slow, (or at least -some- of that page, because I for one am not going to skim through 1000 lines of code), not the page before it.
    the above coding is the restricted page coding which load slow. Actually the scenrio is like this,

    loginpage.php
    restrictedpage.php
    restrictedpage2.php
    restrictedpage3.php
    loginfail.php

    When user use login.php and it will redirect to restrictedpage.php. But when user go either one the restrictedpage without login, the url will change to http://localhost/Web/login.php?acces...estricted2.php and a login.php will prompt to login, once user login, it will load very slow and get that error message.

    Maybe I should post my login.php coding also?

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    That would be a most phantastic(sp?) idea.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    hmm.. how do I input that and flush tag in properly?

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    My login page codings.

    PHP Code:
    <?php require_once('Connections/connLogin.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      
    session_start();
    }

    $loginFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_GET['accesscheck'])) {
      
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }

    if (isset(
    $_POST['username'])) {
      
    $loginUsername=$_POST['username'];
      
    $password=$_POST['password'];
      
    $MM_fldUserAuthorization "";
      
    $MM_redirectLoginSuccess "protected.php";
      
    $MM_redirectLoginFailed "loginfailure.php";
      
    $MM_redirecttoReferrer true;
      
    mysql_select_db($database_connLogin$connLogin);
      
      
    $LoginRS__query=sprintf("SELECT username, user_password FROM phpbb_users WHERE username=%s AND user_password=%s",
        
    GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
       
      
    $LoginRS mysql_query($LoginRS__query$connLogin) or die(mysql_error());
      
    $loginFoundUser mysql_num_rows($LoginRS);
      if (
    $loginFoundUser) {
         
    $loginStrGroup "";
        
        
    //declare two session variables and assign them
        
    $_SESSION['MM_Username'] = $loginUsername;
        
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          

        if (isset(
    $_SESSION['PrevUrl']) && true) {
          
    $MM_redirectLoginSuccess $_SESSION['PrevUrl'];    
        }
        
    header("Location: " $MM_redirectLoginSuccess );
      }
      else {
        
    header("Location: "$MM_redirectLoginFailed );
      }
    }
    ?>

  17. #17
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Nothing here that can really take that long. You've got some seriously weird issues.

    Back to the flush trick. It basically works like this:
    Code:
    echo "Reached this point.<br>\n"; flush();
    Put this in many places in your script, changing the echo text a bit each time. This way you can narrow down where it hangs.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    sorry to ask that is the coding only post @ starting of php coding to the end of php coding, no need to put in after ?> right?

    But I try to put but they never give any errors or I put it the wrong way? I should open all php files that got link with login then put the code eg like below.

    <?php require_once('Connections/connLogin.php'); ?>
    echo "Reached this point.<br>\n"; flush();
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    echo "Reached this point.<br>\n"; flush();
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    echo "Reached this point.<br>\n"; flush();
    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }
    }
    echo "Reached this point.<br>\n"; flush();
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
    session_start();
    }
    echo "Reached this point.<br>\n"; flush();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }
    echo "Reached this point.<br>\n"; flush();
    if (isset($_POST['username'])) {
    $loginUsername=$_POST['username'];
    $password=$_POST['password'];
    $MM_fldUserAuthorization = "";
    $MM_redirectLoginSuccess = "restricted.php";
    $MM_redirectLoginFailed = "loginfailure.php";
    $MM_redirecttoReferrer = true;
    mysql_select_db($database_connLogin, $connLogin);

  19. #19
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Use code tags.

    Those echos are good. Put one before the include, too.

    No, you don't need ?> at the end of the file, though I personally consider it good style. Although I have to admit it has a problem, namely stray newlines after it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  20. #20
    New Member
    Join Date
    Oct 2006
    Posts
    4

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    PHP Code:
    <?php
       
    echo 'Reached line '__LINE__ '<br>\n'flush();
    ?>

  21. #21
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    That's a nice trick. Never thought of it before.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    355

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    Hi thanks for all the reply again. I think the problem should be lies on my restricted php page.

    I do all those flush thingy, I get this error on that restricted page

    Reached line 29
    \n
    Warning: Cannot modify header information - headers already sent by (output started at c:\Inetpub\wwwroot\Login\login.php:29) in c:\Inetpub\wwwroot\Login\login.php on line 72

    That line 72 is header("Location: ". $MM_restrictGoTo);

    I research the information as I think the error is common. But I dunno how should I debug, some call me to put ob_flush also dunno how should I go about it?

  23. #23
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Fatal error Maximum execution time of 30 seconds exceeded

    You should ignore it while debugging. It's telling you that it cannot send HTTP headers after it has sent body content, which is true. Once you remove the debug output, it will work again.

    Question, though: if the redirect is prevented, does the page load completely? If so, then the error is indeed on the page you redirect to, not the login page.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width