| 
	
 | 
 Posted by malatestapunk on 09/07/06 16:01 
Wim Cossement wrote: 
> malatestapunk wrote: 
> > 
> > I'm glad to hear you solved your problem. But just in case you need it 
> > anytime later, you received the error when you tried to send a header 
> > through PHP because there was some output before the header. You should 
> > always send headers first, before anything else goes out. 
> > 
> > regards, 
> > Vladislav 
> 
> Hi Vladislav, 
 
Hello Wim, 
 
 
> 
> It was the 1st line of the PHP code, before preparing and executing the 
> SQL statement. 
> 
> Before that there was just some common HTML, containing the <head> and 
> beginning of the <body>. 
 
 
So there you go :) 
 
Seriously, plain HTML is considered as output as well. Headers should 
be sent before anything else leaves the server. 
 
 
> 
>  From my limited knowledge of HTTP I thought that the headers were 
> always the first data being sent by the webserver, and that this is done 
> automatically. 
> 
 
 
That's true. However, you can set headers from your server side script 
as well. This can come in handy: for instance, when you can't (or 
won't, or aren't allowed to) alter your server configuration. 
 
 
> And I just found out that adding <? header("Content-type: text/html; 
> charset=utf-8"); ?> would do the same as specifying the header in the 
> Apache config or .htaccess file, if the HTTP headers from the website 
> would be turned of, right? 
 
 
Exactly. Since you solved your problem through server configuration, 
you don't have to use it at all - I'm not insisting ;). I was only 
pointing at what was the problem you encountered with headers 
generally. 
 
The same rule applies to cookies and sessions - you must initialize and 
set them before you output anything. 
 
 
>  
> Regards, 
>  
> Wimmy 
 
best wishes, 
Vladislav
 
  
Navigation:
[Reply to this message] 
 |