SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Issues with HEADERS and Server

    I've been working on a website for awhile now and everything works perfectly fine on my WAMP environment. Lately, I uploaded it to the production server to discover that nothing works. Ha. Just my luck!

    So it would seem through looking into the markup to figure out what's up that there's an apparent header issue. Below is the following "Warning" message that I found:

    <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /export/home/account/public_html/user/some_folder/themes/isu_english/header.php:6) in <b>/export/home/user/public_html/some_folder/login.php</b> on line <b>341</b><br />
    Knowing what little I know about this right now, it would seem that some changes I made to the login.php file has caused a bit of a rift with the way some redirects are being used. That's okay because I think I can fix it but it leads me to be curious about my development environment in contrast to the production environment.

    My basic question here is about this header issue: what would cause something like this to work perfectly fine in my development environment and break on the production environment? Something with a PHP directive? The versions of Apache and PHP are the same. I didn't check the MySQL because in my mind, this doesn't relate to that. I might be wrong, though...

    Any ideas would be appreciated. This has me stumped.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The message means something is being output to the web page prior to the headers.

    This can be something like a byte order mark added to the front of files, a space before the <?php at the start of any file, or even a prior error message relating to an error earlier in the file.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Addict bimalpoudel's Avatar
    Join Date
    Feb 2009
    Location
    Kathmandu, Nepal
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    few - BOM Removal - tricks:
    1. "edit /77 <yourfile.php>" and delete first illegal characters.
    2. Open the file in notepad and save it as ascii text.

    Make sure that header.php does not echo/print anything.
    In general do not output anything before setting up cookies, calling sesion_start(), header(), ...

    in worst case (when there are several files to edit for this fix and you want a quick fix for a debug only purpose, remove Byte Order Mark in header.php and put the first PHP code as:

    Code:
    <?php
    ob_start();
    ...
    Bimal Poudel @ Sanjaal Framework over Smarty Template Engine
    ASKING INTERESTING QUESTIONS ON SITEPOINT FOURM

    Hire for coding support - PHP/MySQL

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Also, ZenCart is now advertising a "fix" to the spaces after a ?> in an included file:
    Quote Originally Posted by http://tutorials.zen-cart.com/index.php?article=313
    Symptom
    The ending ?> seems to be missing in some of my files, esp since upgrading to v1.3.8.

    With a Diff viewer I can see that in some cases the last line has changed from ?> to //EOF

    Cause
    This is completely acceptable and has been done intentionally.

    As you may know, if you try to run a PHP file which has whitespace (spaces or blank lines etc) after the final ?> then it can cause problems, usually the dreaded headers already sent error.

    Removing the ?> from php files is a way of mitigating against this error. PHP will quite happily work without it (automatically assuming the closing tag at the end of the file), and thus any whitespace at the end of the file will not cause errors.

    More information can be found here...
    http://www.php.net/basic-syntax.instruction-separation
    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Presumably the // EOF informs everyone that that is actually the end and no lines have been accidentally lost.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •