473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem with headers already sent!

vinci
62
hey guys!

can u help with this!

i uploaded my files into a web hosting site, after that, i made all the necessary changes but when i tried to load the page a warning is being displayed:

"Warning: Cannot modify header information - headers already sent by (output started at /home/www/ycoppettenz.awardspace.com/index.php:8) in /home/www/ycoppettenz.awardspace.com/index.php on line 17"

what should i do??? by the way, i am using php mysql...

also, where can i find a site that is giving a free domain?? hehehe... my website is only a subdomain of awardspace because it is free...hehehe

thanks in advance!!!
Feb 12 '07 #1
4 2135
Motoma
3,237 Expert 2GB
hey guys!

can u help with this!

i uploaded my files into a web hosting site, after that, i made all the necessary changes but when i tried to load the page a warning is being displayed:

"Warning: Cannot modify header information - headers already sent by (output started at /home/www/ycoppettenz.awardspace.com/index.php:8) in /home/www/ycoppettenz.awardspace.com/index.php on line 17"

what should i do??? by the way, i am using php mysql...

also, where can i find a site that is giving a free domain?? hehehe... my website is only a subdomain of awardspace because it is free...hehehe

thanks in advance!!!
DynDNS is a good place to get a free domain.

Your PHP file is trying to send headers, however, headers have already been sent on the page (i.e. you have delivered content to the page, therefore you can no longer send headers).

If you have no idea what I am talking about, post some code and I will point it out.
Feb 12 '07 #2
ronverdonk
4,258 Expert 4TB
I will show the text of an article by wildteen88, june 2006, who can explain this a lot better then I can.

The reason why you are getting this message is because you have may have/be:
  • Whitespace before the opening php tag <?php
  • Outputting something to the browser before you use session_start, header, setcookie etc
session_start, setcookie, header and a few other functions write header information to the web server/browser what to do. Such as when you use session_start it requests the browser to create a cookie which stores the PHPSESSID.

If you have output before you use these functions then they are unable to send new header information as it has already been sent in the form text/html, and so you get the headers already sent error message.

You can easily find the source of the problem by looking at the error message. As the answer is actully in there, but most people dont notice it as they may not understand what the error means. So lets take this error message as an example:

Warning: Cannot modify header information - headers already sent by (output started at C:\server\www\test.php:6) in C:\server\www\test.php on line 8
Now PHP has given us a clue here as it has told use where the output has started! Have look where it says output started at and it gives you the full path to the file and the line number. Now the line number that it stats is not usually where the output has started but where the output has ended, becuase the output could be above that line.
So lets look at test.php:
Expand|Select|Wrap|Line Numbers
  1.  1 <html>
  2.  2 <head>
  3.  3 <title>Header test</title>
  4.  4 </head>
  5.  5 <body>
  6.  6 <?php
  7.  7
  8.  8 header("Location: http://www.google.com");
  9.  9
  10. 10 ?>
  11. 11 </body>
  12. 12 </html>
As you can see line 6 is the opening PHP tag (< ?php) this isn't the output but look above that line you'll notice it has some HTML code. This html code is the cause of the error!

So when you get this error message again look for the clue where it says output started at and goto the file and line number it says. Look above the line number and find where your output is located to.

Hope that helps you understand why your are getting this error message. (Thanks to wildteen88)

Ronald :cool:
Feb 12 '07 #3
devsusen
136 100+
Hi,

If you use any plain html code, whitespace character or php code that can generate output before calling header() function that will cause the error headers already sent......

As response you can't send header more than once. So any output prior to calling header() function will pass the header as response. Henceforth header() function will the error.

Susen
Feb 13 '07 #4
ronverdonk
4,258 Expert 4TB
Hi,

If you use any plain html code, whitespace character or php code that can generate output before calling header() function that will cause the error headers already sent......

As response you can't send header more than once. So any output prior to calling header() function will pass the header as response. Henceforth header() function will the error.

Susen
What does this add to the previous post? Or do I miss something?

Ronald :cool:
Feb 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phyzlo | last post by:
Hello, I've recently started learning PHP and have a question. I tried running below script which can be found at http://se2.php.net/manual/sv/function.setcookie.php but I keep getting this...
2
by: Dariusz | last post by:
I have a problem where when I run the PHP code offline, there are no errors produced and the code runs as expected. However when I uploaded the same script and run it, it says the headers have...
0
by: Bob Bedford | last post by:
I've installed PHP 4.3.6 on my laptop. My dev machine is on PHP 4.3.3 Since, some lines doesn't work anymore: 2: header("Cache-Control: max-age=" . $this->allowcache_expire * 60); gives me...
4
by: Leslie Houk | last post by:
I'm just learning PHP, and I'm having a problem using fpassthru(). I want to download a file using the following code segment I found, which I put into my testing file called portal.php: ...
6
by: Douglas F. | last post by:
My host doesn't use buffering so I placed the form validation (php) ahead of the html like this: <?php if(isset($_POST)) { <do the validation processing> if(file_exists($fn)) {...
4
by: Q | last post by:
Hello, I have composed the following simple php file: <html> <head><title> Title. </title></head> <body> <?php header("Location: http://www.something.com/tmp2.php"); ?> </body>
3
by: lkrubner | last post by:
I'm getting this error: Warning: session_start(): Cannot send session cache limiter - headers already sent in /home/httpd/vhosts/publicdomainsoftware.org/httpdocs/pdsIncludes/McSessionInfo.php...
4
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time...
22
by: Platero | last post by:
Hi, I've a stupid question but... The code is the following: if(($role!='tutor')&&(array_key_exists('tutor_id',$_GET))) { $possible_ids = array(2,6,7,8,9,10); $t_id = $_GET;
4
by: craigtomo | last post by:
I am getting the following error when i try to log on to my data base Warning: session_register() : Cannot send session cookie - headers already sent by (output started at...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.