Add to Google

A Answer Of "headers Already Sent"

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #11) by sobhan on Oct 2 2005, 02:23 PM. (Line Breaks Removed)
This is just becaus you are adding cookies or sessions after 'head' in HTML. I had same problem. I gave cookies before head, and my php script worked.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

A Answer Of "headers Already Sent"

whistle
I install a php script on my trap 17 host. Everything is perfect before I test the script. When I login, it suddenly displays as following:

QUOTE
Warning: Cannot modify header information - headers already sent by (output started at /home/whistle/public_html/center/counter/config.php3:20) in /home/whistle/public_html/center/counter/Change.php3 on line 20


I watch the config.php3, nothing is incorrect. Then I look at the Change.php3, there is nothing wrong. Then I try to find the history topics in the Trap17. It is interesting, I am not the only one in the same trouble. But I can't not find the correct solusion.

There is one who suggests to check whether there is any space before the header() function. I ensure there is no space between <? and ?>, but I found there is two blank line after the "?>" in the config.php. They are blank lines, of course I can't find anything. That's why everything goes wrong. But why this happens?

I recall what I did. I loged into my cpanel, then use the file manager. Afterwards, I chosen the config.php and edited it in the new pop up browser with a default editor in it, then I saved the file. I did not do anything stupid. Finally I find the editor is the trouble maker. Each time I save, It appends another line in the end of my file. It is terrible and stupid tool. If you are a newbie like me, I think you are lucky to read this topic. Yes, you are lucky, because no one ever tell me this and waste me 3 hours. I am lucky too, eventually I find what the problem is. Only 3 hours waste, I almost gave up.

 

 

 


Reply

bureX
Some editors (such as yours) may use different text formatting (such as UTF-8) and may, sometimes, add some invisible characters that PHP sees as characters that have already been outputted to the browser! Really stupid, indeed...

So, be careful while choosing your PHP code editor, or just use Macromedia Dreamweaver! If you choose to stick with your current code editor, make sure that you have chosen the right text formatting.

Reply

biscuitrat
Also, get rid of blank lines beyond the ?> - that always made my wordpress blog mess up.

Reply

Hamtaro
Cpanel's file manager does that to me all the time, and it caused me trouble a while back when I started learning PHP. Now, I just use Notepad (or sometimes, NoteTab). Even Notepad can sometimes also add extra characters (hidden, of course) to files (this happens very rarely to me). Anyway, I'd recommend NOT using the Cpanel editor for PHP scripts like that. It would probably just be easier to make the script on some other editor, then upload via FTP. I've wondered a few times why it adds those extra lines (the Cpanel editor, that is). Anyway, I'm glad you figured it out on your own (even though it did take you a while).

Reply

HmmZ
CODE
Warning: Cannot modify header information - headers already sent by (output started at /home/whistle/public_html/center/counter/config.php3:20) in /home/whistle/public_html/center/counter/Change.php3 on line 20


1: Ensure there are no blank lines before the error
2: Make sure session_start() or cookie setups is/are the very first thing(s) after <?php, meaning it MUST be on line 2
3: Make sure the header is written correctly, it needs a full url and not just "change.php" , but "http://www.your-domain.com/change.php", in some cases, it's not necessary, but it gives you extra insurance that it isnt that
4: If the above dont solve your problem reply, ill dig in further..

Hope it helps

Reply

Spectre
All data sent to a client from a webserver is prefixed with headers informing the client of important information regarding the data (or chunk of data). These can only be sent once - and it occurs when the first lot of output is sent to the client, regardless of what it is. If you get a 'headers already sent' error, it means that some form of output has been sent to the client, either from PHP directly or by the webserver itself (such as, for example, having blank lines before the opening <? tag in a PHP script or having HTML before the PHP code block).

Check line 20 of '/center/counter/config.php3'.

Reply

OpaQue
I havent gone through the replies you recieved above, but this is a very common error.

Headers can be sent only before any output is sent to the client. You must ensure this so that you can easily avoid this error.

LEAVE no space,

before <?, Because, if this is your starting file, then you will get this error.

Now, space after ?> Does not make much sense, but it is good if you dont include spaces after. Because, suppose, you are including a particular file A into B, and if A has space after ?>, then you will definately get the error again.

Create Functions for ERRORs and ALERTS. We usually have a tendency to directly use Print statement. But then, once we do that, we start out the output and we never know, where the output started, if your script is very big. Embedding them in a function will help you pinpoint, where your code is giving output from.

If possible, Create a output class for displaying output to the user. And pass everything to this class. You can then create functions which will buffer this output and give you more control over your script. (This can be achieved using a simple variable too, but it is not soo flexible.)

 

 

 


Reply

Saint_Michael
i notice that you have the php3 as your file just get rid of the 3 and that might help on top of what everyone else has said.

Reply

whistle
I am a novice in php programming. I don't know how to edit programs online. The only tool is the online editor the web hosting gives me. I never notice it adds a new bland line whenever I open a file. It is just like that someone throw garbage to my place and I am not acknowledged. It arises my another question, can I get better tools to edit my programs online?

Reply

Spectre
Personally, I would recommend you use a text editor to modify your scripts locally, then test them on your machine before uploading. If you use Windows, Notepad should do the trick or on *nix, vi should work ok. Keep in mind that a text editor is very different from a word processor, and you obviously don't want the additional formatting a word processor would add to the script.

Reply

Latest Entries

sobhan
This is just becaus you are adding cookies or sessions after 'head' in HTML. I had same problem. I gave cookies before head, and my php script worked.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Similar Topics

Keywords : answer, headers

  1. How Much Would You Be Willing To Pay For These Services?
    Please answer the poll and add your thoughts (2)
  2. Can I Be Selected I Football Clubs
    i need a good answer (1)
    I know good football /cool.gif" style="vertical-align:middle" emoid="B)" border="0"
    alt="cool.gif" /> , so i think i must go for football(soccer) club enterence , do anyone know is
    there any online football club admistions , i need a good website for that ....
  3. Can Somebody Answer My Qustions Please?
    New one needs help:) (8)
    hello every one:) I'm from Poland and I don't understand all of that "read me" things here
    because I'm not familar with english. I'm totally green here. I have some simply quastions.
    Can somebody answer them please? /smile.gif" style="vertical-align:middle" emoid=":)" border="0"
    alt="smile.gif" /> Here they are: 1. Can I make a polish languange site? (off course nothing rude
    or illegal) 2. Can I use a CMS system like JOOMLA! or PHP-NUKE? that's all 4 now i think:)
    I could not handle to find answers by my self. Could any one help me please?....
  4. Group Limitations
    Answer some questions about charectoriation from groups in earlier edu (0)
    I think that groups are very restrictive at schools. You just sort of fit into a group and than
    stay their for the rest of your education. At least at my school we started out as a group in about
    6th grade. After that it is basically the same people every year. Then every now and then their is
    a new student that comes around and all the groups try to get the new guy to join them. I have to
    say that it is somewhat funny how the groups just sort of start calling each other by a certain
    name. For instance in my school we have the farmer hicks, the thespians, and the pe....
  5. Ah, Need A Quick Answer
    (4)
    I have a dell stock motherboard Im buying a new one. the dell stock RAM.... is 333MHz at the
    most.. http://www.compusa.com/applications/Search...&CatId=2014 that is the motherboard.. pic
    of CPUZ Specifications QUOTE Form Factor: ATX Processor Interface: Socket 775
    Processors Supported: Intel Pentium 4 LGA775 Intel 05A Intel 05B Intel Celeron D
    Intel Pentium D Intel Core 2 Duo, Intel Core 2 Extreme, Intel 06, Intel Core 2 Quad
    Additional Technologies: HyperThreading Technology Intel® EM64T, EIST, SLI Ready ....
  6. Changing Domain Name Without Losing High Traffic To My Site
    Need Answer From Admin (13)
    I have a doubt to do what i want, so i am going to the point, m ysituation is that i have a trap17
    free subdomain where i have my free flash clocks website, and its link is
    http://free-flash-clocks.trap17.com . Recently i bought a domain name, its link is
    www.freeflashclocks.com , and what i want to and i am not certain if i can is that i want to,
    redirect all the visits of my free subdmain to my new domain, just for 1 or 2 months, if that is
    possible, i apreciate it if it is not but you allow it because i have thousands of visitors a day
    (~7000/day) and it is growing....
  7. Impossible-to-answer Questions...
    title says it all (2)
    ive got some. How do you explain colours, excluding black and white, and what they look like to a
    blind person that has been blind all his life? Get a red sheet of paper, and stare into it. Look
    closely at the "colour" itself, examine it. Think about what it looks like. Notice after 15 - 30
    secs you cant see the colour. Its invisible. Is that what colour looks like? Why do they have
    frosted windows on the toilets on a plane? and some more... If the Big Bang Theory is true, and
    all matter was condensed into one extremely small and dense area, then what was outside of....
  8. Age Of Empires (please Answer My 1 Second Question)
    A Quick Question (3)
    /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> I Have Age
    Of Empires,But Can Someone Tell Me How To Play Against Other People? ....
  9. What Are Problems?
    An answer by God (6)
    What are Problems ? QUOTE God : Hello. Did you call me? Me: Called you? No.. who is
    this? God : This is GOD. I heard your prayers. So I thought I will chat. Me: I do pray. Just makes
    me feel good. I am actually busy now. I am in the midst of something. God : What are you busy at?
    Ants are busy too. Me: Don't know. But I cant find free time. Life has become hectic. It's
    rush hour all the time. God : Sure. Activity gets you busy. But productivity gets you results.
    Activity consumes time. Productivity frees it. Me: I understand. But I still can&#....
  10. How I Was Born?
    Dad's answer to son's question :-) (12)
    How I was born? QUOTE Son asks his dad, "Daddy, how was I born?" His dad
    sighs and replies, "Ah, my son, I guess one day you would have to find out anyway!" "Well,
    you see your Mom and I first got together in a chat room on MSN. Then I set up a date via e-mail
    with your mom and we met at a cyber-cafe. We sneaked into a secluded room, where your mother agreed
    to a download from my hard drive. As soon as I was ready to upload, we discovered that neither
    one of us had used a firewall, but it was too late to hit the delete button." "Six w....
  11. Errors With Php Setcookie() And Headers! Please Help!
    Having header errors when I try to set a cookie with PHP function setc (2)
    Hey guys, I'm having a problem setting cookies with PHP. I am trying to implement a script that
    will allow someone to log in and access members only pages on my website. One of the aspects is that
    I have to place a cookie on that persons computer. I know that you can use the PHP function
    setcookie() to place it on your computer. The problem is that wherever i have setcookie() in my PHP
    code I get an error: " Warning: Cannot modify header information - headers already sent by (output
    started at /home/runeco/public_html/cookie.php:6) in /home/runeco/public_html/cooki....
  12. Account Created But Can't Access Cpanel
    I read the rules but couldn't find answer (10)
    My hosting is aproved and i got e-mail from xisto company but i can't login to cpanel Can anyone
    in forum help me or do i send mail to xisto?....
  13. Can I Add Forum Gold To My Forum?
    ANSWER FAST PLEASE!! (9)
    ok i am going to get package two....but only if there is a way for me to add forum gold to it.....is
    this poosible???....
  14. A (mostly) Stupid Question.
    ANSWER FAST! Please. (3)
    Well, can I use co.nr domain in the registration form? That's all, answer quickly, please.
    /laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" />....
  15. Domain Name Help
    probably a quick easy answer (5)
    Well I was hosting something on a subdomain because I had extra space and bandwith. And now I
    bought a domain through you guys also. I was justing wondering is there a way to make to make the
    website show up as the domain i bought. Instead of it just redirecting to the subdomain?....
  16. Yahoo! Answers
    Free question and answer service (3)
    About a few weeks ago, I discovered something called Yahoo! Answers (Y! Answers) when on the
    Gahoo!Yoogle site. It is extremely neat! If you have a Yahoo! ID, you can earn points
    in Yahoo! Answers. 100 points for joining and you get up to level 5, well level 7 actually but
    level 5, 6 and 7 are the same. I'm at level 2 right now. You use 5 points for askign questions
    and 1 point for voting and rating answers. 2 points if you answer a question and 10 points for
    getting a best answer. The link is: http://ca.answers.yahoo.com . Check it out....
  17. The Answer Is Google Adsense
    90 % topics here are SCAMS (10)
    Dear all I too have been trying to make money online for a looooong time .. Most of them are SCAMS.
    In surfjunky, i reached payout and they banned me. I think THE best way of earning something for
    real online is by GOOGLE ADSENSE. I was a n00b too. I saw this page and think this will prove useful
    for those who doesnt have an account yet. http://googlefreak.co.nr/adsense.htm It's
    google's and hence, no scam.....
  18. Life: Is The Glass Half Empty Of Half Full?
    My answer to this question (1)
    Is the glass half-empty or is the glass half-full? This question has been plagueing the humna race
    for a while now, and i found the solution. Throw the glass against the floor, and then have no
    glass at all!!! No actually, either way, if you look at the glass as half-empty or
    half-full, the liquid of your choice is still halfway in the glass. I personally choose not to use
    the glass and use a pop bottle instead, so i don;t have to worry about it. It's not a perfect
    solution, actually it's pretty lousy, but it works...sometimes. Once in a blue moon....
  19. What Is God?
    simple question, hard to answer! (52)
    Yeah this is the only thing I'd like to know! Is he a big old man with a beard somewhere
    above us (interstingly what is UP on one side of the earth is DOWN on the other side of it - so
    where is God then if we point up there?)??? Is he inside of us? Are we all a part of god? Is God
    present in everything that surrounds us? Isn't it interesting that GOD is very close to GOOD?
    Maybe it is a metaphore for being and doing GOOD things?? That is something we have inside of us -
    every normal human being has this feeling for what is good and bad and is tryin' to f....
  20. Firefox's Answer To Ie's Phishing Filter?
    users of the sacred browser can breathe once more! (5)
    SiteAdvisor - Firefox's Answer To IE's Phishing Filter? A site-warning plugin
    for ie and firefox Name: Site Advisor Url: http://siteadvisor.com Download:
    http://www.siteadvisor.com/download/ff.html Rating: 9.75/10 Improvements: Not all sites are on
    their database but many of the popular ones are so index all webistes. SiteAdvisor is a simple and
    easy to install extension created for firefox which checks to see if the site you are on is "bad"
    from its database of urls. Once the results have reached your browser a notificatio....
  21. A Puzzle I Dreamt Of.
    Can you help me find an answer? (1)
    Recently I've had the dream that the landmasses around the world have been splitting into fifty
    new islands. All of them were discovered except one. But I found that one and declared myself king
    over it. But the dreams have now left me with a puzzle, one I feel I am inclined to answer. My
    island has attracted the attention of some people, and I have managed to get some people to inhabit
    it. Unfortunately, the food supply is not substantial enough for us all. I need to get more, but I
    have no resources in this country. I could risk travelling to another country, but ....
  22. How To Make A Backbone?
    Is a question, NOT an answer... (3)
    well, i have a big (huge) question, how a ISP make a backbone? thats because in my country
    doesn't exist a backbone(and obiously the speeds are very slow), and i want to know how..... The
    first thing that i think is a huge computer, (or a several group of them) like sgi supercomputers
    but if anyone can help me to understand the way of working of a backbone i will be very pleased,
    Thanks....
  23. Hello, An Introduction
    found this forum while searching for answer (4)
    Well, ive been trying to install my PhpBB fully modded forums, and i keep getting an error, so i
    searched google for a help page (phpbbFM closed their forums), and i came across a topic here!
    Then i decided i wanted to reply to the topic, and here i am. Edited topic and description.
    English only please. ....
  24. Ways To Increase Traffic To My Site
    Can anyone tell me my answer? (7)
    Well im lookin to get traffic onto my website and i was wondering is their an advertising type
    program that trap17 has of their own?? If i posted in wrong area im truely sorry i couldnt find a
    better place /unsure.gif' border='0' style='vertical-align:middle' alt='unsure.gif' /> Edited
    topic title to fit the question. ....
  25. A Physics Challenge
    Can you answer all 13 questions? (15)
    This weekend I found my self unable to post due to my fiancé having a physics test on Monday
    (today). I spent the weekend typing out physics problems for her to solve and now I give them to
    you. I challenge anyone in the Trap 17 forums to answer all 13 questions. Feel free to use any
    resources the vast internet has to offer. So common you physics enthusiasts out there, make
    yourselves known! 1) At exactly noon an object has a displacement of –30m. At exactly 5
    seconds after noon the object has a displacement of –50m. Find the average velocity of the object
    ove....
  26. Jeepers Creepers Best Horror Movie Ever
    go and answer the poll (14)
    Hi People, I would like to start a hole wile a topic of these movie.I have seen this movie a year
    ago.And I think it is the best scary movie ever.I have watched it with my cousin.And even he liked ,
    but he was scared of the movie.I have some reviews found on sites.I will now thell the story.And
    Jeepers Creepers 2 is already out.I will go and buy it from the DVD shop. Some good thing of the
    movie : The performances are solid, the cinematography is fine, and the direction is wonderful.
    The set pieces all look meticulously constructed and the effects are top-notch. Th....
  27. What Is The Answer To This Riddle?
    As above, so below. (13)
    Do You Know the Answer to this Ancient Riddle? QUOTE "The key to life and death is everywhere
    to be found, but if you do not find it in your own house, you will find it nowhere. Yet, it is
    before everyone's eyes; no one can live without it; everyone has used it. The poor usually
    possess more of it than the rich; children play with it in the streets. The meek and uneducated
    esteem it highly, but the privileged and learned often throw it away. When rejected, it lies dormant
    in the bowels of the earth. It is the only thing from which the Philosopher's Stone c....
  28. What's Your Favorite Consula?
    go and answer to the pool (20)
    post replies why you choised this cousola!i want to hear!....
  29. How To Make Pure Html Preloader?
    anyone know's the answer? (7)
    Hello all today i run out on this website and I found it very interesting... Anyone know how they
    did that page? and im specialy interested in that HTML preloader... ?? how to make one??....
  30. My Riddles! - See If You Can Answer Them
    Riddles, riddles & more riddles (18)
    While walking down the street I met a man. He tipped his hat (1) and drew his cane and in this
    riddle I told his name. What is the name of the man? A man walks up to you and says - "everything I
    say to you is a lie." (3) Is he telling you the truth or is he lying? A boy was at a carnival and
    went to a booth where a man said to the boy, "If I write your exact weight on this piece of paper
    then you have to give me $50, but if I cannot, I will pay you $50." The boy looked around
    and saw no scale so he agrees, thinking no matter what the carny writes he'll ....

    1. Looking for answer, headers

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for answer, headers

*MORE FROM TRAP17.COM*
Similar
How Much Would You Be Willing To Pay For These Services? - Please answer the poll and add your thoughts
Can I Be Selected I Football Clubs - i need a good answer
Can Somebody Answer My Qustions Please? - New one needs help:)
Group Limitations - Answer some questions about charectoriation from groups in earlier edu
Ah, Need A Quick Answer
Changing Domain Name Without Losing High Traffic To My Site - Need Answer From Admin
Impossible-to-answer Questions... - title says it all
Age Of Empires (please Answer My 1 Second Question) - A Quick Question
What Are Problems? - An answer by God
How I Was Born? - Dad's answer to son's question :-)
Errors With Php Setcookie() And Headers! Please Help! - Having header errors when I try to set a cookie with PHP function setc
Account Created But Can't Access Cpanel - I read the rules but couldn't find answer
Can I Add Forum Gold To My Forum? - ANSWER FAST PLEASE!!
A (mostly) Stupid Question. - ANSWER FAST! Please.
Domain Name Help - probably a quick easy answer
Yahoo! Answers - Free question and answer service
The Answer Is Google Adsense - 90 % topics here are SCAMS
Life: Is The Glass Half Empty Of Half Full? - My answer to this question
What Is God? - simple question, hard to answer!
Firefox's Answer To Ie's Phishing Filter? - users of the sacred browser can breathe once more!
A Puzzle I Dreamt Of. - Can you help me find an answer?
How To Make A Backbone? - Is a question, NOT an answer...
Hello, An Introduction - found this forum while searching for answer
Ways To Increase Traffic To My Site - Can anyone tell me my answer?
A Physics Challenge - Can you answer all 13 questions?
Jeepers Creepers Best Horror Movie Ever - go and answer the poll
What Is The Answer To This Riddle? - As above, so below.
What's Your Favorite Consula? - go and answer to the pool
How To Make Pure Html Preloader? - anyone know's the answer?
My Riddles! - See If You Can Answer Them - Riddles, riddles & more riddles
advertisement



A Answer Of "headers Already Sent"



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE