SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict tbakerisageek's Avatar
    Join Date
    Sep 2006
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using header('Location: xxx'); Hangs Safari, but EVENTUALLY connects

    Hello all,
    So I've never seen this before and I'm really starting to bang my head against a wall here. Hopefully someone has the answer.

    I've just added a few pages to a site I'm working on, one of which pushes Payment info up to authorize.net and updates some DB content based on the result.

    Upon successful processing, the script writes a few items to DB and then redirects to a "successful payment" page. At first I thought that the authorize.net portion of the script was hanging me up, but doing a
    "tcpdump src test.authorize.net proved that was not the case as that traffic came back almost instantly. I also put a bunch of break points echoing into the page to give me the status of when things happened.

    I then looked at my MySQL queries to make sure they weren't hanging up by enabing the Query logging in MySQL and tailing that log, and actually re-running the queries that were hitting the database to make sure they processed correctly.

    Once I've done all this, I started isolating more in the PHP what might be hanging up, and my testing concludes that the header('Location: upgradesuccessful.php'); is happening (by observing that the URL is changing within the browser), but no content is loading in the page for over a minute.

    What's most peculiar is that it works just fine some of the time, and other times it does not. Restarting Apache always fixes the problem, and once the script is hung up, executing that same page from another browser on the same system has the same result. I can't seem to get Internet explorer to hang on this page at all, and was wondering if it was isolated to Safari.

    This wondering caused me to do a few quick google searches, and I did turn up a blog posting stating that you need header('Content-Length: 0'); in there as well but this didn't seem to help.

    I've spent countless hours held up on continuing development due to this bug. Here's to hoping someone can help me out. I've got faith in all of you...

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This might sound basic, but it needs to be asked.

    Do you have an exit; statement after your header relocation?
    e.g.:
    PHP Code:
    header('Location: upgradesuccessful.php');
    exit; 
    If not, you should otherwise the PHP engine will keep running the script after the header(), which could hang the browser. An exit; statement will ensure the script stops.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Addict tbakerisageek's Avatar
    Join Date
    Sep 2006
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And here I was spending 5 hours last night troubleshooting the problem pulling out all the Sys Admin stops...

    Arkinstall, Thanks for pointing out the obvious. I think I missed it because it was the last line of a switch case and was so focused on the break; I needed.

    I think I've either got to stay fully in PHP or get out of it all together, these month long gaps in programing are clearly hurting me. Thanks again.

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Don't worry, it's a common mistake to make.

    If you want to keep your mind into PHP, just have a side project that work on for ten minutes each day (assuming an otherwise busy life).
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •