Getting php error on production but not development - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Getting php error on production but not development (/showthread.php?tid=52403) |
Getting php error on production but not development - El Forum - 06-08-2012 [eluser]Cgull[/eluser] Hello, I have this web site where I get this error on live: A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /home/highland/public_html/application/controllers/order/checkout.php:203) Filename: libraries/Session.php Line Number: 672 But not on my local server. Any idea why would this happen? Getting php error on production but not development - El Forum - 06-09-2012 [eluser]GI-Joe[/eluser] [quote author="Cgull" date="1339224452"]Hello, I have this web site where I get this error on live: A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /home/highland/public_html/application/controllers/order/checkout.php:203) Filename: libraries/Session.php Line Number: 672 But not on my local server. Any idea why would this happen?[/quote] Please show you code Getting php error on production but not development - El Forum - 06-09-2012 [eluser]Cgull[/eluser] I am posting the code of the function that it looks like it is moaning about: Code: function calcDelivery() Line 203 is this one: Code: echo "R "; Thank you Getting php error on production but not development - El Forum - 06-09-2012 [eluser]GI-Joe[/eluser] Please check whether you are printing anything before redirecting to a view or some url in checkout.php Getting php error on production but not development - El Forum - 06-09-2012 [eluser]GI-Joe[/eluser] Just try by removing Code: //echo "R "; You should not print anything before using Code: redirect('path/to/method/or/view'); Getting php error on production but not development - El Forum - 06-09-2012 [eluser]Cgull[/eluser] Thank you, I will look into moving the printf and echo to the view itself, but still, why don't I get this error on the local machine? Getting php error on production but not development - El Forum - 06-09-2012 [eluser]Cgull[/eluser] Sorry, another thing, this function is being called in a view with an ajax call: Code: $(document).ready(function() Getting php error on production but not development - El Forum - 06-09-2012 [eluser]CroNiX[/eluser] CI's output is buffered when using views, etc. When you echo directly from a controller, that output gets sent immediately followed by the contents of the buffer. It's best to send any output to the buffer instead of echoing it directly. Code: $output = "R "; Your session is sending output to the browser (probably a cookie, sent with a header), so that's where the buffering is coming into play. |