SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    NJ
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script running twice

    I've got a script I'm working on that is being run twice each time it's called from the browser. There aren't any calls made to header(location). The wierd part is that the script runs fine on my server at work but not on my home server. I thought the configs were the same for php on both machines.

    Is there a php.ini or even an apache config setting that would cause a script to be run twice as if I'd made a call to header(location) to the same script? I just know I'm going to kick myself over this one but I'm stumped and starting to go cross-eyed from staring at script dump logs.

    Thanks,
    CHris.

  2. #2
    SitePoint Zealot DerelictMan's Avatar
    Join Date
    Oct 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chrisjohnson
    Is there a php.ini or even an apache config setting that would cause a script to be run twice as if I'd made a call to header(location) to the same script? I just know I'm going to kick myself over this one but I'm stumped and starting to go cross-eyed from staring at script dump logs.

    Thanks,
    CHris.
    This is a long shot, but make sure you don't have any img tags that have empty src attributes. (For example a literal src="" or maybe a dynamic src attribute that is populated by a PHP variable that happens to be empty or false for some reason). If your browser is given an img tag with "" as the src it may interpret this as "the current location" which would make it request the page twice (or more). This has happened to me on more than one occasion, oddly enough.

  3. #3
    SitePoint Evangelist ghurtado's Avatar
    Join Date
    Sep 2003
    Location
    Wixom, Michigan
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In addition to what DerelictMan pointed out and related to it, are you using mod_rewrite?
    Garcia

  4. #4
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you want to provide us with some of the code that exerts bad smells?

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    NJ
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script isn't using mod_rewrite. Just to make sure, I copied the php.ini-dist file to php.ini just to make sure I was running clean.

    The image tags were fine, I have any images that are used default to a blank spacer if the real one doesn't exist.

    I'll see what I can post code wise later today. I've got jury today. Joy.

    thanks for the tips,

    Chris

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    NJ
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem Solved ... somehow

    Quote Originally Posted by DerelictMan
    This is a long shot, but make sure you don't have any img tags that have empty src attributes. (For example a literal src="" or maybe a dynamic src attribute that is populated by a PHP variable that happens to be empty or false for some reason). If your browser is given an img tag with "" as the src it may interpret this as "the current location" which would make it request the page twice (or more). This has happened to me on more than one occasion, oddly enough.
    Just tried it again, the only chages I had made since last night is adding a placeholder image to an image that actually was empty. It works now. I guess the session hadn't cleared out when I tried it this morning.

    Thanks,
    Chris.


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
  •