Please help: Error - Circular Redirection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry

    Please help: Error - Circular Redirection

    Hi All

    I would very much appreciate your help:
    I have two scripts alternating in the background triggering themselves
    mutually. Here is how:

    1.)
    Script A does something and then calls Script B through the header()
    function. Using something like
    header("Locatio n:http//mydomain.com/scriptb.php");

    2.)
    Script B then does something as well and afterwards calls Script A
    again also using the header() function.

    After exactly 10 rounds my browser suddenly shows an PHP error message
    which mentions a "circular redirection" error aborting the script.

    QUESTION:
    Is there a way to avoid that error?

    PURPOSE:
    The two-script-concept was supposed to be a solution to prevent
    time-outs during time consuming processes by simply handing the
    process over to another script before the time limit is reached thus
    initiating a new script session by the other script which would
    continue the process. In other words: The process is being kicked back
    and forth between the two scripts until it's finished.

    Any ideas ???? Thank you guys.
    Jerry
  • Christian Fersch

    #2
    Re: Please help: Error - Circular Redirection

    Jerry wrote:[color=blue]
    > After exactly 10 rounds my browser suddenly shows an PHP error message
    > which mentions a "circular redirection" error aborting the script.[/color]
    This is a protection so a script can't end in an endless redirection-loop.
    [color=blue]
    > Is there a way to avoid that error?[/color]
    You could try meta-refreshs, but there could also be a configuration
    directive, settings this.

    Comment

    • Ray Morgan

      #3
      Re: Please help: Error - Circular Redirection

      Jerry <none@none.co m> wrote:
      [color=blue]
      >Hi All
      >
      >I would very much appreciate your help:
      >I have two scripts alternating in the background triggering themselves
      >mutually. Here is how:
      >
      >1.)
      >Script A does something and then calls Script B through the header()
      >function. Using something like
      >header("Locati on:http//mydomain.com/scriptb.php");
      >
      >2.)
      >Script B then does something as well and afterwards calls Script A
      >again also using the header() function.
      >
      >After exactly 10 rounds my browser suddenly shows an PHP error message
      >which mentions a "circular redirection" error aborting the script.
      >
      >QUESTION:
      >Is there a way to avoid that error?
      >
      >PURPOSE:
      >The two-script-concept was supposed to be a solution to prevent
      >time-outs during time consuming processes by simply handing the
      >process over to another script before the time limit is reached thus
      >initiating a new script session by the other script which would
      >continue the process. In other words: The process is being kicked back
      >and forth between the two scripts until it's finished.
      >
      >Any ideas ???? Thank you guys.
      >Jerry[/color]

      Ouch! Why not just change the timeout setting in php.ini?


      --
      Ray Morgan

      Comment

      • Dana Cartwright

        #4
        Re: Please help: Error - Circular Redirection

        When I do a long-running process on a shared server, I find that if I issue
        a short 'sleep' call ever few seconds, I can run a process for a long time
        (hours and even days), even though I'm running on a server in which there is
        a 30-second timeout for runaway processes.

        The 'sleep' is a way to yield the processor, giving other processes a chance
        to run.

        So you might simplify your processing in this way, using a single PHP
        script, rather than flipping back and forth between two pages. It should be
        easier for you to write, and might even impose less load on your server.

        --
        --------------------
        My e-mail address doesn't have a 2 in it.
        "Christian Fersch" <Chronial@web.d e> wrote in message
        news:c9q9p9$aa5 $05$1@news.t-online.com...[color=blue]
        > Jerry wrote:[color=green]
        > > After exactly 10 rounds my browser suddenly shows an PHP error message
        > > which mentions a "circular redirection" error aborting the script.[/color]
        > This is a protection so a script can't end in an endless redirection-loop.
        >[color=green]
        > > Is there a way to avoid that error?[/color]
        > You could try meta-refreshs, but there could also be a configuration
        > directive, settings this.[/color]


        Comment

        • Rook

          #5
          Re: Please help: Error - Circular Redirection

          if you just want the script to run without dying, but you don't care about
          seeing the end-result in the browser you can...
          <?
          function this_function()
          {
          // do a bunch of wacky stuff here...
          }
          ?>

          or.. if you want to see something in the browser.. you can do something like
          this. (This is from actual working code I wrote a long time ago... i
          trimmed out the stuff specific to my application but you should get the
          idea...)
          <?
          set_time_limit( 0);
          session_start() ;

          // the setup...
          if (!isset($_SESSI ON['count'])) {

          $_SESSION['count'] = 0;

          $_SESSION['chunks'] = array_chunk(fil e('/some/file.txt), 50);

          $_SESSION['start_time'] = date("Y-m-d H:i:s");
          $_SESSION['chunk_count'] = count($_SESSION['chunks']);

          header('Locatio n: ' . $_SERVER['PHP_SELF']);
          exit();

          // the run through
          } else {

          ++$_SESSION['count'];

          echo 'Start Time: ' . $_SESSION['start_time'] . '<br />';
          echo 'Pass: ' . $_SESSION['count'] . ' of ' .
          $_SESSION['chunk_count'] . '<br />';

          if (isset($_SESSIO N['chunks'][0])) {

          foreach ($_SESSION['chunks'][0] as $k => $v) {

          $line = trim($v);

          //
          // your code to do something with the line goes here.
          //

          } // END foreach loop

          array_shift($_S ESSION['chunks']);
          echo '<META HTTP-EQUIV="REFRESH" CONTENT="0; url=' .
          $_SERVER['PHP_SELF'] . '">';

          } else {

          // must be done! Display the results.
          $_SESSION['end_time'] = date("Y-m-d H:i:s");

          echo '<pre>';
          print_r($_SESSI ON);
          echo '</pre>';

          }

          }

          ?>


          "Jerry" <none@none.co m> wrote in message
          news:un61c05ijr 09in81vcrohqasc h2p4o4d49@4ax.c om...[color=blue]
          > Hi All
          >
          > I would very much appreciate your help:
          > I have two scripts alternating in the background triggering themselves
          > mutually. Here is how:
          >
          > 1.)
          > Script A does something and then calls Script B through the header()
          > function. Using something like
          > header("Locatio n:http//mydomain.com/scriptb.php");
          >
          > 2.)
          > Script B then does something as well and afterwards calls Script A
          > again also using the header() function.
          >
          > After exactly 10 rounds my browser suddenly shows an PHP error message
          > which mentions a "circular redirection" error aborting the script.
          >
          > QUESTION:
          > Is there a way to avoid that error?
          >
          > PURPOSE:
          > The two-script-concept was supposed to be a solution to prevent
          > time-outs during time consuming processes by simply handing the
          > process over to another script before the time limit is reached thus
          > initiating a new script session by the other script which would
          > continue the process. In other words: The process is being kicked back
          > and forth between the two scripts until it's finished.
          >
          > Any ideas ???? Thank you guys.
          > Jerry[/color]


          Comment

          • Jerry

            #6
            Re: Please help: Error - Circular Redirection

            Hello People!

            Thank you so far. I will try your suggestions.
            Nevertheless, I'm afraid the problem persists because I would need a
            solution which allows me to close the browser once the process has
            been triggered. Any ideas on this?
            Your help is greatly appreciated.
            Jerry

            On Fri, 04 Jun 2004 18:11:10 +0200, Jerry <none@none.co m> wrote:
            [color=blue]
            >Hi All
            >
            >I would very much appreciate your help:
            >I have two scripts alternating in the background triggering themselves
            >mutually. Here is how:
            >
            >1.)
            >Script A does something and then calls Script B through the header()
            >function. Using something like
            >header("Locati on:http//mydomain.com/scriptb.php");
            >
            >2.)
            >Script B then does something as well and afterwards calls Script A
            >again also using the header() function.
            >
            >After exactly 10 rounds my browser suddenly shows an PHP error message
            >which mentions a "circular redirection" error aborting the script.
            >
            >QUESTION:
            >Is there a way to avoid that error?
            >
            >PURPOSE:
            >The two-script-concept was supposed to be a solution to prevent
            >time-outs during time consuming processes by simply handing the
            >process over to another script before the time limit is reached thus
            >initiating a new script session by the other script which would
            >continue the process. In other words: The process is being kicked back
            >and forth between the two scripts until it's finished.
            >
            >Any ideas ???? Thank you guys.
            >Jerry[/color]

            Comment

            Working...