This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
My site is running fine on one server but when I shifted it to another server, some pages are giving following warning message.
Warning: Cannot modify header information - headers already sent by (output started at /home/parviz/public_html/ganj_videos/lang/english.php:1) in /home/parviz/public_html/ganj_videos/mobile/detect.php on line 50
Any idea on how to fix it?
Thanks.
Most likely your new server has a different setting for the errors and warnings. If PHP issues a warning or error as output then it will cause your headers to fail.
Change the level using the error_reporting function.
Just follow the debug: it says output started in file /home/parviz/public_html/ganj_videos/lang/english.php on line 1. There's most probably some messy newlines or spaces there. Make sure all php files executed start with <?php and NOTHING else before it, or you'll get the warning.
Related
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 7 years ago.
i have uploaded my project on the server but when i try to run it it shows this warning. However on my local machine every thing is working just perfect what could be the problem.
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/prosyst2/public_html/sms/index.php:1) in /home/prosyst2/public_html/sms/auth.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at /home/prosyst2/public_html/sms/index.php:1) in /home/prosyst2/public_html/sms/auth.php on line 8
You can't set session/cookie after you echo'd something or generated some output.
You can use ob_start(); at the beginning of the file and echo ob_get_clean(); at the end to buffer the output.
Your local php installation does not report warnings correctly, set it to report E_ALL, which is errors, warnings, notices etc, and the other way on the server.
When it comes to your specific problem, you have output before your session_start(); call, this could be html or anything that writes to the output buffer, or incase session_start(); is on the top of the page, possibly a BOM character.
How to fix:
Never do any output before sending headers (header(...), session_start() etc) and this wont happen.
Always report all errors and warnings etc on a development installation, so you know whats wrong.
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 8 years ago.
I just migrated a wordpress site from a local xampp server running on my Windows 8 PC to a cpanel hosting account which I use to host a few other sites.
Post migration the site seemed to be working well, until I tried saving a page in the wordpress admin. Upon saving, I encountered the error message shown further down the page.
I have attempted to troubleshoot to the best of my ability, including following the steps on the wordpress site for this particular error. So far, to no avail.
If I disable the nextgen gallery plugin, the problem goes away. I require the plugin to display images on the site though, so it's not a solution.
Interestingly enough, the changes do get saved, despite the error.
If anyone can help me figure out this problem I will be forever grateful!
Many thanks
Warning: preg_match() expects parameter 2 to be string, array given in
/home/ascothou/public_html/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_resource_manager.php
on line 36
Warning: strpos() expects parameter 1 to be string, array given in
/home/ascothou/public_html/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/admin/admin.php on line 63 Warning: Cannot modify header information - headers
already sent by (output started at
/home/ascothou/public_html/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_resource_manager.php:1)
in
/home/ascothou/public_html/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/frame_communication/class.frame_event_publisher.php
on line 74
Warning: Cannot modify header information - headers already sent by
(output started at
/home/ascothou/public_html/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_resource_manager.php:1)
in /home/ascothou/public_html/wp-admin/post.php on line 222
Warning: Cannot modify header information - headers already sent by
(output started at
/home/ascothou/public_html/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_resource_manager.php:1)
in /home/ascothou/public_html/wp-includes/pluggable.php on line 899
2 possible reasons.
You screwed that page up, and PHP generates warnings (which you have seen), and then the warnings are printed to the browser, which prevents the headers being modified.
You saved the page with UTF-8 BOM, which is sent to browser before the header modification.
More like the 1st reason.
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 8 years ago.
So I'm trying to change the headers in PHP with this code:
header("HTTP/1.0 404 Not Found");
And I get the following error message:
Cannot modify header information - headers already sent by (output
started at path\index.php:1)
So I've read about this error, and I found out that it happens because an output is already sent before I'm trying to change the headers. Problem is it tells me that output is sent in index.php on line 1, yet line 1 on that file is:
<?php
I've checked and there is no whitespace characters before the <. I even tried to change the first line of the file to:
<?php header("HTTP/1.0 404 Not Found");
Yet I still get the same error.
Why does this happen and how can I solve it?
I could be BOM related. This is related to the editor you use and which encoding you save in.
Please check
UTF-8 BOM signature in PHP files
EDIT:
Actully check this answer instead. How to fix "Headers already sent" error in PHP .. its great.
I don't know for sure what caused this problem, but eventually after I changed 'php.ini' (to install PDO) and restared the server I managed to change headers via PHP successfully.
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
I have created a dynamic menu CMS website. I developed in a Windows system. When i run my project in windows operating system, My project runs without any error. But now uploaded it into Linux Operating system server i am getting warning & error like:
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/ansofcm8/public_html/apps/resources/math/application/core/MY_Controller.php:1)
Filename: libraries/Session.php
Line Number: 675
What could be the reason. Please help me.
There seems to be whitespace before the php open tag <?php in MY_Controller.php.
Check all PHP files and remove the whitespace before the <?php tag. If there is a space or new line, the body of the http request is started, and you can't add new headers to the http request.
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
I tried to move my codeigniter server folder to Amazon EC2 server.
I zipped whole file with "tar cvfpz" command and move the file to new server.
I unzipped by using "tar xvfpz" command.
My new server setting is fine, but I get this error.
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/playmobs/_application/controllers/home.php:188)
Filename: core/Common.php
Line Number: 442
404 Page Not Found
The page you requested was not found.
I checked the database config file and all other config files.
All of them have correct commands for new server.
Can you see why I see this error?
Thank you.
You get this error, because probably you send output before sending header. This error can have a lot of reasons.
Here is really well documented solution: How to fix "Headers already sent" error in PHP
I solved the problem.
The reason was that I moved to the new server and didn't turn on PHP short cut command.
my code was like this.
<? ----- ?>
New server php didn't recognized this one.