This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 10 years ago.
I realise this has been asked many times, and the answer is usually some whitespace before or after the PHP tags however I have checked all my files and not found any evidence of this.
I am using Wordpress and have debug mode switched on. My site works on one domain however I recently moved it to a new server (still running apache on linux - I did move from shared to a VPS) and gave it a new domain. All I have changed is the following in wp-config.php:
define('DB_NAME', 'new db name');
define('DB_USER', 'new db user');
define('DB_PASSWORD', 'new db password');
define('WP_HOME','new url');
define('WP_SITEURL','new url');
However I am now unable to log in, I have narrowed this down to the fact cookies are not being set. If I visit wp-login.php I get the following errors:
Warning: Cannot modify header information - headers already sent by (output started at /home/rcnhca/public_html/wp-includes/load.php:270) in /home/rcnhca/public_html/wp-login.php on line 368
Warning: Cannot modify header information - headers already sent by (output started at /home/rcnhca/public_html/wp-includes/load.php:270) in /home/rcnhca/public_html/wp-login.php on line 380
Note: Both wp-login.php and load.php are core Wordpress files.
line 368 of wp-login.php is:
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
and line 380:
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
line 270 of load.php is:
ini_set( 'display_errors', 1 );
However I also recieve the following warning:
Warning: ini_set() has been disabled for security reasons in /home/rcnhca/public_html/wp-includes/load.php on line 270
Which I believe is because I have the Suhosin PHP patch installed but I am not definite on this. I do not want to run a more vulnerable version of PHP.
I can't work out why this error is occurring, there is no trailing whitespace in any of my theme's PHP files.
Note: I also realise I can use output buffering to solve this, however I want to understand where the problem is occurring instead of applying a one-size fits all patch which will affect my debugging capabilities.
The ini_set() warning causes the headers to get sent which in turn triggers the "cannot modify headers" messages.
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 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.
I use shoppica theme for opencart. When I log in as a test customer and click on order history section I always get a internal server error 500. I haven't changed anything in .htaccess nor in config file. It was from the begging but from now on I need it. All the sections in customer panel works except order history and transaction section. One clue is, when I give a reward transaction to my customer the transaction section which was before in the panel would disappeared and gave me an internal 500 error. Please help me as I need it a lot.
I can't install it again because it is for 3 months and I can't start from the beginning.
I use opencart 1.5.3.1
for another internal error I got these errors in my log:
PHP Warning: unlink(public_html/system/cache/cache.currency.1358109327) [<a href='function.unlink'>function.unlink</a>]: No such file or directory in public_html/system/library/cache.php on line 14
PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at public_html/index.php:104) in public_html/system/library/session.php on line 11
PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at public_html/index.php:104) in public_html/system/library/session.php on line 11
PHP Warning: Cannot modify header information - headers already sent by (output started at public_html/index.php:104) in public_html/index.php on line 177
PHP Warning: Cannot modify header information - headers already sent by (output started at public_html/index.php:104) in public_html/vqmod/vqcache/vq2-system_library_currency.php on line 45
you should check the unlink function
I'm a bit too late for this particular question, but since it has quite a bit of views I'll provide an answer nevertheless.
For anyone else struggling with 500 Server Errors in OpenCart – the first thing to do when debugging these is to look into your server's error log and find the exact error message.
If there aren't any, you may need to enable them explicitly by adjusting the error_reporting, display_errors and log_errors settings in your PHP configuration. You can also temporarily change them in your main index.php file directly.
Once you know the exact error message, fixing it is a simple process.
We've covered some of the most common OpenCart error messages causing 500 Server Errors in our blog post: Server Errors and Blank Pages in OpenCart: Most Common Causes.
In this particular case, the issues are caused by the fact that your cache folder is either missing or not writable by the server:
PHP Warning: unlink(public_html/system/cache/cache.currency.1358109327) [function.unlink]: No such file or directory in public_html/system/library/cache.php on line 14
This error indicates your OpenCart currency cache file is missing. In most cases, it happens when your system/cache/ folder lacks correct server permissions (for OpenCart, it's usually 775). It should be fixed by adjusting folder permissions and removing all of the existing cache files from inside the folder.
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/moonpk/public_html/wallz/preview.php:16) in /home/moonpk/public_html/wallz/loginbox.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/moonpk/public_html/wallz/preview.php:16) in /home/moonpk/public_html/wallz/loginbox.php on line 2
i am getting these two warning which i was not getting on local server... why ....
See the first note on the php session_start() page. session_start() sends cookies to the browser, and the server will not send any additional data (including cookies) after any data has already been sent. This can simply be fixed by making sure that nothing is being sent to the browser (such as an echo() or var_dump() call) before calling session_start().
You don't get them on local server because you have lower errer reporting level on it. So, you need:
On you local server edit php.ini and set error_reporting to E_ALL
Move you session_start() call before line 16 of you /home/moonpk/public_html/wallz/preview.php file
Most likely you have some whitespace outside any PHP-tags in files that are loaded before the session_start() is executed. Maybe your FTP client messed things up?
You probably had warnings suppressed on your local server? The issue is that you have some output before you call session_start. Judging by the line numbers, I'd guess you have a line break before your opening php tag, but without seeing the code, can't provide a full solution.
If you are including the page "preview.php" within "loginbox.php" check that you have only called session_start once on one page.
Either on preview.php or loginbox.php , not both.