SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Possible reasons for script causing browser to hang?

    I have a script that is causing the browser(any browser I try it in) to hang. It is definitely the PHP as there's no other iffy factors in the page. I've double checked for possible infinite loops, and it doesn't seem there is the possibility for one anywhere. What other circumstances can account for this behavior?

  2. #2
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ummm...make sure there isnt anything in that page calling itself. kinda of an infinite loop, but you might have checked for other kinda loops.

    i had a page calling itself...lol...was funny. it'd hang and then give me a "page cannot be displayed" message.

    edit: oh, post some code.

  3. #3
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure I want to post a 300+ line script here. There are definitely no infinite loops, as I mentioned in the intial post, and it's definitely not calling itself.

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Check all your SQL queries. I had a script that something was wrong with one of my queries (can't remember now) and it caused my browser to hang and when I hit Ctrl-Alt-Del my Apache.exe was using 98% of my CPU

  5. #5
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All the queries seem fine. This is beyond weird.

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Lol, do you use an OS that will tell you your CPU usage? If so, check it while the browser is hanging and isolate the program that is causing the infinite loop.

  7. #7
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did something like this recently, couldn't work out why I was crashing PHP and Apache with just a cookie script. Turns out, when I was creating a cookie, I would check if it existed and if so, then delete it. This was okay (except pointless) until I ran a deletion function, which called the create function. Obviously, the cookie existed, so it called the delete function, which called the create function, which called the delete function, which called the create function, etc...

    Check you don't have silly errors like this or like this:

    PHP Code:
    <?php
    while (true) {
        
    // do something
    }
    ?>
    -Peter

  8. #8
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe I should bold the "I checked for infinite loops" part in the first post (no offense meant to anyone, but that's what everybody keeps asking )

    dj p@ckman:I'm running this on a hosted server (since it needs to access the production database) The browser is using around 20% CPU at hang, but I wonder what the host's Apache is doing?

  9. #9
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Oh, well I have no idea what you could do now Maybe run the script locally and connect to the online DB (if you have an IP address) and see what happens then, otherwise, I'm stumped

  10. #10
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    anode, as the answer is quite often infinite loops that is the response you will get as its the first point of call - as you aren't posting any code its not something we can all check either - bit like the chicken and the egg setup !

    Anyway my advice would be to comment out nearly all of your code until you get to a point where the page doesn't hang and then uncomment small parts at a time until you get it to hang.. standard debugging technique for me.. that should hopefully highlight the area you need to analyse. Start by not including your include files that type of thing eventually you will be able to identify the source of the error.. well I hope so

    And if not you will then hopefully have a smaller section of code which you can post in the hope someone can find out why its doing it.

    Be interesting to know what the problem is so if you find it please post it..

    Sarah
    Regular user

  11. #11
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dj p@ckman - I'm pretty sure they don't allow remote DB connections.

    Sarah, I'm off to try that now. I've tried to avoid that whole can of worms(it's a pain to have to keep force quitting and restarting!), but now's the time. I'd post the code, but I think 300 lines is wayyy too long for a forum.

  12. #12
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I quite agree that 300 is TOO long - hopefully this way will help you cut that down to a size that is postable

    good luck..!
    Regular user

  13. #13
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't just upload it as .phps ? it would make it easier to look at your code

    I've accidently missed out a a single line in some asp code and made the server crash because it couldnt handle that many records! But since you say it'snot because of a loop...

  14. #14
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .phps = ?

    Anyway, back from uncommenting. Weirder and weirder: the hangup seems to be a require_once'd file is being called infinitely for whatever reason. The file in question does NOT call itself(nor should it even be able to since require_once was used.) It is definitely not stuck in a larger loop, as when the require_once statement was commented out, everything was peachy keen.

  15. #15
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Try changing require() to include(), maybe you'll get a better response Require give a fatal error but Include only give a warning, maybe it'll tell you what the warning is for

  16. #16
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    include_once() has the same results as require_once(). No warnings popped up before HTML output started.


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
  •