Results 1 to 2 of 2

Thread: PHP include not working properly in IE

  1. #1
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy PHP include not working properly in IE

    Hey all,

    I'm using PHP include to pull in html from external .php files to build a page (using like SSI). In Chrome/Firefox/Safari it works great, but in IE the included html shows up in random areas of the page.

    For example, my code is:

    Code:
    <div id="topArea">
    
      <!-- BEGIN HEADER FRAG -->
      <?php include("header.php"); ?>
      <!-- END HEADER FRAG -->
      
      <!-- BEGIN NAVBAR FRAG -->
      <?php include("navbar.php"); ?>
      <!-- END NAVBAR FRAG -->
    
    </div> <!-- /topArea -->
    
    <div id="homepageContent">
    
    Some content
      
    </div> <!-- /homepageContent -->
    In this example, Chrome, Firefox and Safari all render the html from header.php in the topArea div, like it should. But in IE, sometimes it will render header.php in the homepageContent div. Any idea why this would be happening? Thank you!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That's not possible. Or at least it cannot be for the reason that you believe.

    PHP operates on the server and generates text. Then it sends that text to the browser-- that browser can be IE, firefox, or just a plain text reader (for example, if you saved the file rather than viewing it), and it would never change the content of the page.


    It is theoretically possible to use some PHP code to try to see what browser is being used and intentionally change this, but it's not 100% reliable, and it certainly wouldn't ever happen by accident.


    My suggestion is to open the page in both browsers then use "view->source" to see what is actually being sent by the server. They should be identical.
    Then IE is doing something strange with the code, which is not a PHP issue-- Javascript, or HTML formatting, etc.

    If you actually find that the source code is different in the browsers (that would be surprising!) then you should save the version that Firefox loads (file>save as) and open that file in IE. My guess is that you will have the same problem then as well-- it's the generated code, not the PHP.

    Finally, if you do determine that the HTML (+JS, CSS) is the problem, then you should put it in the validator to find out what is wrong.
    http://validator.w3.org/

    My first guess is that you are not generating valid code because you are including a full HTML page inside another full HTML page, resulting in very broken code. What you need to do is have one full HTML page that you use as a base, then use include() with partial HTML pages, such as just the code for a single <div> or anything else that would be long in the page. Using include() is a convenience for you as the coder, but it does NOTHING to fix broken HTML or make two pages magically fit together that should not.

    If you still need help, can you provide a link to your page? From what you've said at the moment, it's not possible to help more because PHP is simply not designed to ever have that kind of error.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Tags for this Thread

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
  •