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@xxxxxxxxx> To: php-objects@xxxxxxxxxxxxxxx Sent: Friday, 24 June 2011 5:22 PM Subject: Re: 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@xxxxxxxxxxxxxx> > ** > > > 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]