www.webdeveloper.com
Results 1 to 4 of 4

Thread: Headers already sent?

  1. #1
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280

    Headers already sent?

    hi, I made a style sheet that the content is generated via SQL info. It woks fine on test servers in the office, but on a live site, it always says the headers are already send.
    Warning: Cannot modify header information - headers already sent by (output started at /home/df420/public_html/somedir/template/style.php:1) in /home/df420/public_html/somedir/template/style.php on line 1
    And here is the first 50 lines of the file.
    PHP Code:
    <?php header('Content-type: text/css');
    require_once(
    '../includes/settings.php');
    require_once(
    '../includes/db.inc.php');
    require_once(
    '../includes/style.inc.php');
    $s $style->getStyle();?>
    /* Dynamic CSS Document */
    html{
    <?php
    foreach($s['html'] as $a){
        echo 
    $a['attribute'].':'.$a['value'].';'."\n";
    }
    ?>
    }
    body {
        font-size: 10pt;
        margin: 0 0 0 0;
        font-family: Myriad Pro, Tahoma, Verdana, Arial, Helvetica, sans-serif;
    }
    h2{
    <?php
    foreach($s['h2'] as $a){
        echo 
    $a['attribute'].':'.$a['value'].';'."\n";
    }
    ?>
    }
    h3{
    <?php
    foreach($s['h3'] as $a){
        echo 
    $a['attribute'].':'.$a['value'].';'."\n";
    }
    ?>
    }
    th {
        text-align: left;
    }

    td {
        padding: 0px 0px 0px 0px;
    }

    div.main {
        width: 1000px;
        margin: 0px auto 0px auto;
    }

    td.top_left {
        background: url("../images/template/top_left.png");
        width: 244px;
        height: 157px;
    }

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    If the file is saved as UTF-8, make sure it is saved wtihout a BOM (byte order mark), which would be output before your opening <?php tag (or just save it as plain ASCII text if you don't really need the extended UTF-8 character set).

    If that's not it, is it possible your web host has an auto_prepend_file configured in your php.ini settings (or apache config/.htaccess) which might be generating output?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    Awesome, it was the encoding. Thanks a lot.

    EDIT: Just out of curiosity, why would it be fine locally and not work remotely?
    Last edited by NoEffinWay; 01-30-2013 at 12:03 PM.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    Possibly something to do with the FTP client or file upload page you used to deploy it to the web host?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles