• Help
  • Search
  • Login
  • Register
  • Home

Forum: web design and graphics community

Celestial Star Forum > Web Development > Coding > some warnings
Pages: [1]
« previous next »
  Print  
Author Topic: some warnings  (Read 993 times)
Lily
Skogul
**
Posts: 47



View Profile WWW
some warnings
« on: January 15, 2007, 08:57:48 PM »

Warning: Cannot modify header information - headers already sent by (output started at /path/to/gifts.php:2) in /path/to/cookiecheck.php on line 17

i had this problem on like 2 of my pages. what i don't understand is that i have the same script for all my pages and only them two are acting. i was thinking maybe it could be a cache problem or somthing that's wrong with my computer. but today someone just told me that they see it too on theirs. so i'm not sure what's happening anyone have an idea?
Logged

Digital Lavender x ABC Board x Self-Assured

Blackstone
Administrator
Valkyrie Randgris
*****
Posts: 821

Oh look! People!


View Profile
some warnings
« Reply #1 on: January 15, 2007, 09:16:43 PM »

I received that error as well, and was just about to tell you about it... but now I saw this post.

So I'll tell you that an error like that normally occurs when you try to set a cookie after you have started the <head> tag in your HTML already. Double-check on those pages where you receive the errors to make sure that you are setting cookies before you open your HTML header.
Logged
Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
some warnings
« Reply #2 on: January 16, 2007, 04:25:50 AM »

Actually Blackstone that's not quite correct. All document headers must be sent before any output is sent to the browser, so cookies, mime-types, redirections, they all need to be set before the very first character of the page is set, otherwise they get an error.
Logged

Melfina
Administrator
Valkyrie Randgris
*****
Posts: 1289



View Profile WWW
Re: some warnings
« Reply #3 on: January 16, 2007, 08:48:07 AM »

If you have an include for, let's say your database information, then have a header('Location: '); after, it throws those errors, you shouldn't use includes with that. That's the most common error for me, so maybe it will help you.

If any of the previous posts or this one helped you, please paste the code for the page that's giving you trouble, removing the db password etc, and we'll see if we can spot the error (don't worry, you can just delete the whole coding once your problem is solved).
Logged


MySpace  ~ MySpace Codex ~ Rune Nifelheim
Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
some warnings
« Reply #4 on: January 16, 2007, 09:39:38 AM »

The only time an include would affect it would be if the include echos content to the page, all headers must go before any content, otherwise they're invalid. Cookies are headers and as such must be set before the content loads, otherwise an output buffer needs to be set to set a cookie after content has been displayed on the page.
Logged

Lily
Skogul
**
Posts: 47



View Profile WWW
some warnings
« Reply #5 on: January 16, 2007, 04:07:47 PM »

well i don't use it with a database and i don't use an echo after it either.
i use that for skinning layouts and such.

all my pages already have a "header.php" included right before the page contents. in the 'header.php' i have another set of inclusions to the cookiecheck.php and another page called headerx.php

All header.php and headerx.php pages are seperate and i made sure that there are no mistakes with the naming and such.

i didn't use header('Location: '); either.

but maybe it's too many inclusions? i donno
Logged

Digital Lavender x ABC Board x Self-Assured

Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
some warnings
« Reply #6 on: January 16, 2007, 04:35:00 PM »

Go to gifts.php, on line 2 the output is starting there, you then try to send another header in cookiecheck.php on line 17, which is failing. Fix the issue in gifts.php, then cookiecheck.php will be able to set the cookie correctly getting rid of the error.

You can't have too many inclusions, also a typo in the file name in an inclusion would produce a different error than what you have gotten.
Logged

Lily
Skogul
**
Posts: 47



View Profile WWW
some warnings
« Reply #7 on: January 17, 2007, 07:21:37 PM »

you say fix the issue, but i don't know how to fix it or make it better becuase my other pages work.. that's why. i'd understand why you wouldn't want to have too many inclusions
Logged

Digital Lavender x ABC Board x Self-Assured

Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
some warnings
« Reply #8 on: January 18, 2007, 07:39:27 AM »

Any kind of input being sent to the browser before a header will cause the header to fail. If you open gifts.php and go to line 2, there will be some piece of coding that is generating text for the browser before you attempt to create the cookies, my guess is you're including a file after it that sets the cookies.

The line could be an echo, or something as stupid as an unset variable which would generate an E_NOTICE error message. Either way there is some piece of coding there that is generating page content thus ending the potential to create headers.

If you can't figure it out, then paste the first 5 lines of gifts.php and I'll tell you what the problem is.

There is no problem with having a lot of includes, it is infact arguably better to have many includes. Having many includes gives you the potential of splitting your coding into many blocks, making it easier to manage and debug.
Logged

Lily
Skogul
**
Posts: 47



View Profile WWW
some warnings
« Reply #9 on: January 18, 2007, 05:35:23 PM »

my first 5 lines of gifts.php is this
Code:



in my cookiecheck.php i have this (cookiecheck was for skinning)
Code:




ehh you're probably wondering what header.php is.. this is what is in header.php
Code:



that's 2 inclusiond in a row. gifts.php included header.php, but header.php includes cookiecheck.php and headervar thing...
should i delete '<?php' in header.php? since inside the inclusion it's already php?? or no.. cuz i'm not sure about that
Logged

Digital Lavender x ABC Board x Self-Assured

Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
some warnings
« Reply #10 on: January 18, 2007, 07:58:20 PM »

As strange as it may sound, the only thing that I can see that would be affecting it is your whitespace... try removing the line break above each <?.

Do not remove the <?php and ?> from header.php, they're needed to inform the server that it is php coding you're parsing, otherwise it will just output a syntax error.
Logged

Lily
Skogul
**
Posts: 47



View Profile WWW
some warnings
« Reply #11 on: January 19, 2007, 09:10:07 PM »

as strange as it may sound?? yea it did sound kind of strange.. well actually really strange. but you were right!!!!!!!!
when i deleted that line break, it worked!! that's so weird!
thanks so much Vangs..
Logged

Digital Lavender x ABC Board x Self-Assured

Blackstone
Administrator
Valkyrie Randgris
*****
Posts: 821

Oh look! People!


View Profile
some warnings
« Reply #12 on: January 20, 2007, 12:09:38 AM »

xD That's funny that a line break would do that. o.o Odd...

Okay, random pointless comment, definitely. Glad you all got it figured out, though.
Logged
Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
some warnings
« Reply #13 on: January 20, 2007, 11:46:57 AM »

Quote from: "Lily"
as strange as it may sound?? yea it did sound kind of strange.. well actually really strange. but you were right!!!!!!!!
when i deleted that line break, it worked!! that's so weird!
thanks so much Vangs..


Your welcome Smiley. The whitespace was being detected as HTML in the script because it was outside the php tags, so it was sending content to the browser before setting the headers, hence why the error was being given. :D Glad you got it sorted though.
Logged

Pages: [1]
  Print  
« previous next »
 
Jump to:  

  • Welcome, Guest
  • Members login
  • Register for free

General

  • General
  • New members
  • Announcements
  • Support / Suggestions

Art boards

  • Creative mediums
  • Requests and offers
  • Tutorials
  • Celestial Star tutorials

Web development

  • Coding
  • Web design
  • Advertisements / affiliation

Off-topic

  • The non-sense
  • Ententainment

Go up
eXTReMe Tracker
  • Valid XHTML
  • Valid CSS
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC | Seo4Smf v0.2 © Webmaster's Talks
Loading...