Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
headers already sent
#1
Hello again

on my local wamp I don't have the error, but when put on the production server my in-development plugin generates the error
Code:
Warning: Cannot modify header information
headers already sent by (output started at /path/to/getsimple/admin/inc/template_functions.php:27)
looking briefly at the template_functions.php file with its ob_start and ob_end this seems normal (so maybe I should save the datas more elegantly using an ajax request instead of using a header:Location trick as I mimicked what is done in the pages.php file) but what may be going on differently on the local server vs the distant server that don't make it throw the error ?

Now that I think about it : I don't use the same theme locally and on the webserver so I think I know what's wrong : my them doesn't have a functions.inc.php file while the default theme (on the server) has.
Reply
#2
(2014-03-08, 05:07:23)Bertrand Wrote: Now that I think about it : I don't use the same theme locally and on the webserver so I think I know what's wrong : my them doesn't have a functions.inc.php file while the default theme (on the server) has.
nope I just checked and it's a wrong explanation, so it's still a mystery to me.
Reply
#3
template file might have newlines after closing php tag?
Or one of its includes?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#4
actually template_functions.php does

remove that and see if it helps.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
and the difference would be one has output_buffering on in php
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#6
spot-on, that's a php config issue.
Reply
#7
Not really the solution but it would fix it. Still curious what was the problem
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
I checked and the issue was indeed exactly what you spotted : my WAMP installation has php output_buffering on, I turned it off and the header warning happened as on the distant server.

In case someone has the same issue with WAMP (the packaged software) simply add
Code:
php_flag "output_buffering" off
in your root .htaccess file to turn it off.
Reply
#9
Usually you have to set this in php.ini, rare that a host allows this in htaccess
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
sorry for my inaccuracy : it works with WAMP
Reply
#11
Regarding my initial headers issue, as I hated a javascript redirect workaround, I finally decided to do the saving in a admin-pre-header hook, using a hidden form field identifying my plugin not to interfere with other stuff - save me the hassle of using a separate ajax request (which can also be handled in a admin-pre-header hook now that I think about it) and keeps everything in a unique file - that I like a lot.
Reply




Users browsing this thread: 2 Guest(s)