228 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United Kingdom
stevebluck says

Hey guys and gals,

I’m having trouble with something. I’m saving a css file via php with this code:

header("Content-type: text/css");

Now I need to include wp-blog-header.php in order to use Wordpress’s functions so It now looks like this:

include '../../../wp-blog-header.php'; 
header("Content-type: text/css");

After these lines of code I have some basic CSS styling and it all works fine on my host, hosted by heartinternet and my local server which is on my PC. However on some hosts I get the error:

Warning: Cannot modify header information - headers already sent by (output started at /bla bla bla) in /bla bla bla/colours.php on line 3

Why would this error happen on only SOME hosts? I just don’t understand.

Thank you in advance.

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 4-5 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

Hi, try including wp-load.php instead.

193 posts
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 and 1 000 dollars
Kontent says

Hi, add this line below the

< ?php
ob_flush(); // add this line
then before the ending
? >
Add:
ob_end_flush(); 

This should fix the problem.

228 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United Kingdom
stevebluck says
Hi, try including wp-load.php instead.

This fixed the issue!

That was seriously driving me nuts! Thanks unisphere.

by
by
by
by
by
by