Stuck in an infinite loop >.<

Discussion in 'PHP' started by timallard, Oct 14, 2009.

  1. #1
    I am trying to create a "Database is now being updated" landing page, which would show up for the 30-60 seconds while the my db is being updated.

    I see this happening like this:

    When the update process gets initiated, it updates the config table saying "updating = true".

    I do a query on each page (my dconfig.php since it is on every page) looking for "updating = true".

    If it finds updating = true, i redirect to the "dont worry, we are just updating the DB" page.

    What is happening, is, i am being stuck in an infinite loop.. and dont know how to get around it.

    I know i can do an htaccess file, but im not sure how to dynamicly update it automatically.

    here is my php code thus far..


    
    $updatingNow = 'True';
    
    if ($updatingNow == 'True'){
    $landingPage = "updating"; 
    }
    
    
    if ($landingPage == 'updating'){
    header ('Location: dont-worry.php');
    }
    
    PHP:
    but since this is in the header of every page it starts the loop from the beginning. The "dont worry page" has a variable called "$page = 'updateLandingPage';" if that can be used in the if statement..

    any help would be appreciated,

    thank you!
     
    timallard, Oct 14, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm, bit unclear exactly to what it is you are doing. This sounds like the perfect time to use AJAX and have that dynamically update what stage the proecess is at
     
    JAY6390, Oct 14, 2009 IP
  3. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #3
    basically while the database is updating, i need to redirect the users to a different page, once the updating is complete, people can resume using the tool hmmm
     
    timallard, Oct 14, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    if ($landingPage == 'updating' && $page != 'updateLandingPage'){
    header ('Location: dont-worry.php');
    }
    PHP:
    You can also check that $_SERVER['REQUEST_URI'] is not a specific URL. Something like if ($_SERVER['REQUEST_URI'] != '/dont-worry.php') {} should work.
     
    premiumscripts, Oct 14, 2009 IP
  5. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #5
    perfect, thank you this worked.
     
    timallard, Oct 14, 2009 IP