228 posts
  • 7 Years of Membership
  • Affiliate Level 1
  • Collector Level 4
  • Exclusive Author
+2 more
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
  • Affiliate Level 2
  • Author Level 9
  • Collector Level 2
  • Top Monthly Author
+7 more
unisphere
says

Hi, try including wp-load.php instead.

193 posts
  • 6 Years of Membership
  • Author Level 2
  • Exclusive Author
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
  • 7 Years of Membership
  • Affiliate Level 1
  • Collector Level 4
  • Exclusive Author
+2 more
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