Loading ...
Sorry, an error occurred while loading the content.
 

Re: [php-objects] css/header problems

Expand Messages
  • Altamiro Teixeira de Souza
    Hi Martin ! This problem normaly occurs when blank lines or spaces exist on the top of the program. Delete every blank line at the top and bottom of each
    Message 1 of 4 , Jun 24, 2011
      Hi Martin !
      This problem normaly occurs when blank lines or spaces exist on the top of
      the program. Delete every blank line at the top and bottom of each progrom .


      Miro

      2011/6/24 Martin <martin@...>

      > **
      >
      >
      > Hi,
      >
      > I have a program that works very well on my machine (Win7 apache 2.2 php
      > 5.3.2) As soon as I copied it to the godaddy hostin account I got the
      > "header already sent error" I made a compare between the 2 files and they
      > came up identical the code - even stripped down to the following still
      > produced the error
      >
      > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
      > <html><script type="text/javascript" src="myjs.js"></script>
      > <head><LINK rel="stylesheet" href="mystyle.css" type="text/css"></head>
      > <?php
      > session_start();
      > echo '<body><div class="div1">Hello world</div></body>';
      > ?>
      >
      > I subsequently changed it to
      >
      > <?php
      > session_start();
      > echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">';
      > $h = '<script type ="text/javascript">function loadjscssfile(filename,
      > filetype){
      > if (filetype=="js"){ //if filename is a external JavaScript file
      > var fileref=document.createElement("script")
      > fileref.setAttribute("type","text/javascript")
      > fileref.setAttribute("src", filename)
      > }
      > else if (filetype=="css"){ //if filename is an external CSS file
      > var fileref=document.createElement("link")
      > fileref.setAttribute("rel", "stylesheet")
      > fileref.setAttribute("type", "text/css")
      > fileref.setAttribute("href", filename)
      > }
      > if (typeof fileref!="undefined")
      > document.getElementsByTagName("head")[0].appendChild(fileref)
      > }</script>';
      > echo $h;
      > $h = '<script type ="text/javascript">loadjscssfile("myjs.js",
      > "js");loadjscssfile("mystyle.css","css");</script>';
      > echo $h;
      > echo '<html>';
      > echo '<body><div class="div1">Hello world</div></body>';
      > ... some more code here ...
      > ?>
      >
      > This got rid of the "header already sent problem but now the program works
      > but without any of the of the styles applied. The routines in the myjs.js
      > all work quite nicely. but why not the style. All the session stuff seems to
      > work just as expected too.
      >
      > except the part
      >
      > if (!isset($_SERVER['PHP_AUTH_USER']))
      > {
      > $session_id = $_SESSION['session_id'];
      > header('WWW-Authenticate: Basic realm="My Program ' . $session_id .
      > '"');
      > header('HTTP/1.0 401 Unauthorized');
      > echo 'You have to enter a valid user name and Password - Not logged in';
      > exit;
      > }
      >
      > that again sends the header already sent error. I could write another
      > password entry program but I'd rather fix the underlying program
      >
      > If I look at the webpage in IE (by hitting F12) all the HTML code looks
      > exactly like it is supposed to.
      >
      > Any ideas?
      >
      >
      >



      --
      Altamiro Teixeira de Souza


      [Non-text portions of this message have been removed]
    • Udayakumar Sarangapani
      Hi Martin, You have to follow W3C standards always... 1) You have to keep your JS, CSS files in the section. 2) session_start() should be the first line
      Message 2 of 4 , Jun 26, 2011
        Hi Martin,

        You have to follow W3C standards always...

        1) You have to keep your JS, CSS files in the <head> section.
        2) session_start() should be the first line in your PHP code.
        3) Once you use header() function, no echo or text content should be placed before that.

         
        Thanks & Regards
        Udayakumar Sarangapani
        Chennai.

        "Science is nothing but logic..."



        ________________________________
        From: Altamiro Teixeira de Souza <mirotsster@...>
        To: php-objects@yahoogroups.com
        Sent: Friday, 24 June 2011 5:22 PM
        Subject: Re: [php-objects] css/header problems

        Hi Martin !
        This problem normaly occurs when blank lines or spaces exist on the top of
        the program. Delete every blank line at the top and bottom of each progrom .


        Miro

        2011/6/24 Martin <martin@...>

        > **
        >
        >
        > Hi,
        >
        > I have a program that works very well on my machine (Win7 apache 2.2 php
        > 5.3.2) As soon as I copied it to the godaddy hostin account I got the
        > "header already sent error" I made a compare between the 2 files and they
        > came up identical the code - even stripped down to the following still
        > produced the error
        >
        > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
        > <html><script type="text/javascript" src="myjs.js"></script>
        > <head><LINK rel="stylesheet" href="mystyle.css" type="text/css"></head>
        > <?php
        > session_start();
        > echo '<body><div class="div1">Hello world</div></body>';
        > ?>
        >
        > I subsequently changed it to
        >
        > <?php
        > session_start();
        > echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">';
        > $h = '<script type ="text/javascript">function loadjscssfile(filename,
        > filetype){
        > if (filetype=="js"){ //if filename is a external JavaScript file
        > var fileref=document.createElement("script")
        > fileref.setAttribute("type","text/javascript")
        > fileref.setAttribute("src", filename)
        > }
        > else if (filetype=="css"){ //if filename is an external CSS file
        > var fileref=document.createElement("link")
        > fileref.setAttribute("rel", "stylesheet")
        > fileref.setAttribute("type", "text/css")
        > fileref.setAttribute("href", filename)
        > }
        > if (typeof fileref!="undefined")
        > document.getElementsByTagName("head")[0].appendChild(fileref)
        > }</script>';
        > echo $h;
        > $h = '<script type ="text/javascript">loadjscssfile("myjs.js",
        > "js");loadjscssfile("mystyle.css","css");</script>';
        > echo $h;
        > echo '<html>';
        > echo '<body><div class="div1">Hello world</div></body>';
        > ... some more code here ...
        > ?>
        >
        > This got rid of the "header already sent problem but now the program works
        > but without any of the of the styles applied. The routines in the myjs.js
        > all work quite nicely. but why not the style. All the session stuff seems to
        > work just as expected too.
        >
        > except the part
        >
        > if (!isset($_SERVER['PHP_AUTH_USER']))
        > {
        > $session_id = $_SESSION['session_id'];
        > header('WWW-Authenticate: Basic realm="My Program ' . $session_id .
        > '"');
        > header('HTTP/1.0 401 Unauthorized');
        > echo 'You have to enter a valid user name and Password - Not logged in';
        > exit;
        > }
        >
        > that again sends the header already sent error. I could write another
        > password entry program but I'd rather fix the underlying program
        >
        > If I look at the webpage in IE (by hitting F12) all the HTML code looks
        > exactly like it is supposed to.
        >
        > Any ideas?
        >

        >



        --
        Altamiro Teixeira de Souza


        [Non-text portions of this message have been removed]



        ------------------------------------

        Are you looking for a PHP job?
        Join the PHP Professionals directory Now!
        http://www.phpclasses.org/jobs/
        Yahoo! Groups Links



        [Non-text portions of this message have been removed]
      • amit
        Hi Martin, put following lines in header file, & first line of file and check is there is an blank space before and after
        Message 3 of 4 , Jun 27, 2011
          Hi Martin,

          put following lines in header file, & first line of file
          <?php
          ob_start();
          ?>
          and check is there is an blank space before and after "<?php" remove the spaces.



          --- In php-objects@yahoogroups.com, "Martin" <martin@...> wrote:

          >
          > Hi,
          >
          > I have a program that works very well on my machine (Win7 apache 2.2 php 5.3.2) As soon as I copied it to the godaddy hostin account I got the "header already sent error" I made a compare between the 2 files and they came up identical the code - even stripped down to the following still produced the error
          >
          > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
          > <html><script type="text/javascript" src="myjs.js"></script>
          > <head><LINK rel="stylesheet" href="mystyle.css" type="text/css"></head>
          > <?php
          > session_start();
          > echo '<body><div class="div1">Hello world</div></body>';
          > ?>
          >
          > I subsequently changed it to
          >
          > <?php
          > session_start();
          > echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">';
          > $h = '<script type ="text/javascript">function loadjscssfile(filename, filetype){
          > if (filetype=="js"){ //if filename is a external JavaScript file
          > var fileref=document.createElement("script")
          > fileref.setAttribute("type","text/javascript")
          > fileref.setAttribute("src", filename)
          > }
          > else if (filetype=="css"){ //if filename is an external CSS file
          > var fileref=document.createElement("link")
          > fileref.setAttribute("rel", "stylesheet")
          > fileref.setAttribute("type", "text/css")
          > fileref.setAttribute("href", filename)
          > }
          > if (typeof fileref!="undefined")
          > document.getElementsByTagName("head")[0].appendChild(fileref)
          > }</script>';
          > echo $h;
          > $h = '<script type ="text/javascript">loadjscssfile("myjs.js", "js");loadjscssfile("mystyle.css","css");</script>';
          > echo $h;
          > echo '<html>';
          > echo '<body><div class="div1">Hello world</div></body>';
          > ... some more code here ...
          > ?>
          >
          > This got rid of the "header already sent problem but now the program works but without any of the of the styles applied. The routines in the myjs.js all work quite nicely. but why not the style. All the session stuff seems to work just as expected too.
          >
          > except the part
          >
          >
          > if (!isset($_SERVER['PHP_AUTH_USER']))
          > {
          > $session_id = $_SESSION['session_id'];
          > header('WWW-Authenticate: Basic realm="My Program ' . $session_id .
          > '"');
          > header('HTTP/1.0 401 Unauthorized');
          > echo 'You have to enter a valid user name and Password - Not logged in';
          > exit;
          > }
          >
          > that again sends the header already sent error. I could write another password entry program but I'd rather fix the underlying program
          >
          > If I look at the webpage in IE (by hitting F12) all the HTML code looks exactly like it is supposed to.
          >
          > Any ideas?
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.