Re: css/header problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-objects/join
    (Yahoo! ID required)

<*> To change settings via email:
    php-objects-digest@xxxxxxxxxxxxxxx 
    php-objects-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux