Professional Web Applications Themes

Please help: Error - Circular Redirection - PHP Development

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("Location: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 ...

  1. #1

    Default 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("Location: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
    Jerry Guest

  2. #2

    Default Re: Please help: Error - Circular Redirection

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

  3. #3

    Default 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($_SESSION['count'])) {

    $_SESSION['count'] = 0;

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

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

    header('Location: ' . $_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($_SESSION['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($_SESSION['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($_SESSION);
    echo '</pre>';

    }

    }

    ?>


    "Jerry" <nonenone.com> wrote in message
    news:un61c05ijr09in81vcrohqasch2p4o4d494ax.com...
    > 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("Location: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

    Rook Guest

  4. #4

    Default 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 <nonenone.com> wrote:
    >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("Location: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
    Jerry Guest

Similar Threads

  1. Error attempting to write location redirection
    By Homero in forum Coldfusion Server Administration
    Replies: 0
    Last Post: March 31st, 04:09 PM
  2. Redirection limit error
    By johndoe01 in forum Macromedia ColdFusion
    Replies: 3
    Last Post: February 24th, 09:10 PM
  3. circular use bug?
    By Jim Thomason in forum PERL Miscellaneous
    Replies: 2
    Last Post: September 3rd, 01:32 AM
  4. error report redirection
    By Ronald J Marchand in forum SCO
    Replies: 6
    Last Post: July 18th, 03:57 AM
  5. circular border
    By Lisa in forum Macromedia Fireworks
    Replies: 1
    Last Post: July 11th, 06:54 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139