Re: header problem

[email protected] ("Mike Frazer") Mon, 29 Oct 2001 14:44:32 -0500
Newsgroups php.lang
Message-ID <[email protected]>
There may not be a way to solve the probem.  The only way I can think of is
to remove all calls to the header() function in your scripts.
Unfortunately, these are usually used for a reason.

You can also try putting all processing code before the <html> tag.  That
can sometimes have an effect on how data is sent.  Once the server
processing reaches the <html> tag it sends headers.

Mike Frazer





"Wujj" <[email protected]> wrote in message
news:[email protected]...
> i signed up for a free host which support php,but the server will add a
> javascript to my php page,it cause a header error like
>
>
> Warning: Cannot add header information - headers already sent by (output
> started at
>
/usr/home/hosting/users/phpnewbie/www/phpnewbie.host-ing.com/nntp/thread.php
:11)
> in
>
/usr/home/hosting/users/phpnewbie/www/phpnewbie.host-ing.com/nntp/thread.php
> on line 1
>
>
> and the script is:
>
> <script language=javascript>
> var url = "http://banner.host-ing.com/content/2";
> var domain = "";
> var min_timeout = 5;
> expired = document.cookie.indexOf("popunder");
> var enabled = testCookie()
> if (!enabled) {
> expired = 0;
> }
> if (expired == -1) {
> setCookie(min_timeout);
> popUnder();
> }
> function setCookie(min_timeout) {
> var d = new Date();
> var timeout = d.getTime() + (min_timeout * 60 * 1000);
> var expires = new Date();
> expires.setTime(timeout);
> var stamp = d.valueOf();
> if (document.domain.indexOf(domain) == -1) {
> domain = "";
>
> }if (domain.length > 0 ) {
> domain = "domain=." + domain + ";";
> }
> var expires_str = expires.toGMTString();
> var cookie_str = "popunder=" + stamp + ";path=/;"
> cookie_str +=  domain + "expires=" + expires_str;
> document.cookie = cookie_str;
> }
> function testCookie() {
> var enabled = navigator.cookieEnabled
> if (enabled == null) {
> var d = new Date();
> var timeout = d.getTime() + (1 * 60 * 1000);
> var expires = new Date();
> expires.setTime(timeout);
> var expires_str = expires.toGMTString();
> var test_str = "bluefishCookieTest=" + 1 + ";path=/;"
> test_str +=  domain + "expires=" + expires_str;
> document.cookie = test_str;
> enabled = document.cookie.indexOf("bluefishCookieTest");
> if (enabled == -1) {
> return 0;
> }
> }
> else {
> if (!enabled) {
> return 0;
> }
> }
> return 1;
> }
> function popUnder() {
> var h = 342;
> var w = 468;
> props = "width=" + w + ",";
> props += "height=" + h + ",";
> props += "titlebar=0,";
> props += "toolbar=0,";
> props += "location=0,";
> props += "menubar=0,"
> props += "scrollbars=0,"
> props += "resizable=1,"
> props += "channelmode=0,"
> props += "directories=0,"
> props += "status=0,";
> props += "top=9000,left=9000";
> var popwin = window.open("","popwin",props,true);
> popwin.location = url;
> popwin.opener.focus();
> }
> </script>
>
>
>
>
>
> so who can tell me how to slove the problem,thanx
>