Thanks Jenif

Yep, another thank you for JeniF

You simply rock JeniF. Thank you SO much!!!

try placing this at the top of your page:
<? ob_start(); ?>

then at the bottom of the page place this line of code:

<? ob_flush(); ?>

I was unable to log into wordpress and this helped me out, I have no idea why it happened as I have not edited any files recently but this fixed it, Thanks alot!

Hey you don't need to worry about this problem
Just after the </html> code write this code ob_end_flush(); if you have used header('location:...');
Better user ob_start while using header tag and ob_end_flush after header('location:..')

K now I tried updating a page and I get this.
Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-content/plugins/great-real-estate/templatefunctions.php:1737) in /home/litt6041/public_html/listing/wp-includes/pluggable.php on line 936

line 936

header("Location: $location", true, $status);

there can be no whitespace before a header, there is a tab in the code above, CDF

there can be no whitespace before a header, there is a tab in the code above, CDF

I Tried that same problem, thanks for the help.

To all: if header() php function is use for redirecting, then an exit is required, to prevent some of the body data sent to buffer (only header needed):

<?php
header('Location: http://www.domain.com/new-page.php');
exit;
?>

Note: it is recommended to write the full URL of the new location, like in my example.

Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-includes/pluggable.php:1) in /home/litt6041/public_html/listing/wp-login.php on line 353

Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-includes/pluggable.php:1) in /home/litt6041/public_html/listing/wp-login.php on line 365

Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-includes/pluggable.php:1) in /home/litt6041/public_html/listing/wp-includes/pluggable.php on line 739

Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-includes/pluggable.php:1) in /home/litt6041/public_html/listing/wp-includes/pluggable.php on line 740

Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-includes/pluggable.php:1) in /home/litt6041/public_html/listing/wp-includes/pluggable.php on line 741

Warning: Cannot modify header information - headers already sent by (output started at /home/litt6041/public_html/listing/wp-includes/pluggable.php:1) in /home/litt6041/public_html/listing/wp-includes/pluggable.php on line 936

try placing this at the top of your page:
<? ob_start(); ?>

then at the bottom of the page place this line of code:

<? ob_flush(); ?>

thank u .......!

thanks to whiteLeo from 2007. it helped me a ton to know HTML tags cannot be place above header. I am now sane again. :')

Thank you so much JeniF :).

I am having the same issue I have tried adding the ob_start() and ob_flush() and the beginning and end of the script but I still am having the issue

<?php

include('config.php');

ob_start();
@session_start();

if (!isset($_POST['login'])) {

?>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
	<fieldset>
		<legend>Login</legend>
		<table>
			<tr>
				<td>Email </td>
				<td><input type="text" name="email" /></td>
			</tr>
			<tr>
				<td>Password </td>
				<td><input type="password" name="password" /></td>
			</tr>
			<tr>
				<td><input type="submit" name="login" value="Login" /></td>
			</tr>
			<tr>
				<td><a href="<?=$siteurl?>/register.php">Register</a></td>
			</tr>
		</table>
	</fieldset>
</form>
<?php
}
else
{
	//Declare some variables
	$email = secure($_POST['email']);
	$password = secure($_POST['password']);
	
	//Check if the form is filled out
	if (!$email || !$password)
	{
		echo 'Please fill out the form completely';
		echo '<a href="'. $siteurl .'/login.php">Go Back</a>';	
	}
	else
	{
		$user = mysql_query("SELECT * FROM `users` WHERE email = '$email'");
		
		if (!	mysql_num_rows($user))
		{
			echo 'That user doe not exist';
		}
		else
		{
			//Encrypt the password
			$encpass = sha1($password . $salt);
		
			//Find the user
           	$superquery = mysql_query("SELECT * FROM `users` WHERE email = '$email' AND password = '$encpass'");
           	
           	if (mysql_num_rows($superquery) == 1) {

            	//If the user is found, set the cookies
            	
                setcookie("username", $email, 0);
                setcookie("password", $encpass, 0);
                setcookie("is_logged_in", true, 0);


                //send the user to the home page
				header("Location: " . $siteurl . "members.php");

         	} 
         	else 
         	{
	
    	     	echo 'Password was incorrect. Please try again.';

        	}
		}
	}
}

ob_flush();
?>
commented: start your own thread, do not hijack some elses, clean your code -3

Put ob_start(); on line 1. It needs to be the very first thing, above <?php
Therefore ob_flush(); also needs to be the very last thing. HTH

commented: incorrect answer, do not follow this advice, anything outside <?php ?> is treated as html and causes the rrors quoted -3

Ignore Morphim, incompetent, anythiing outside of <?php ?> will be another cause of the error given, not a solution
try

<?php obj_start();
// bla bla bla code
obj_flush(); ?>

use a code highlighting editor to highlight missing closing braces etc, not suggesting there are any, havent looked, dont care,
get rid of bs whitespace

if (!	mysql_num_rows($user))		{			echo 'That user doe not exist';		}

looks and functions better as

if(!mysql_num_rows($user)){echo 'That user doe not exist';}

START YOUR OWN THREAD for your own questions
morons(Morph) and obnoxious ba***rds(yours truly) reply to solved threads

Thanks JeniF... also 4 years after

{snipped - expletive} genius!

Thank you so much JeniF!! i solved my problem now... more power to you.. i really like this site.. its very useful...godbless for all..^_^..

try placing this at the top of your page:
<? ob_start(); ?>

then at the bottom of the page place this line of code:

<? ob_flush(); ?>

Thanks you very much!

Hi,
These terms have been highlighted:
cannot modify header information - headers already sent

solution:
Just add ob_start() near to php

ex;

<?php ob_start()

?>

i tried this. this was worked+

Thank you for the info guys

you can change document encoding to "ansi" . always use powerfull editor same as dreamveaver or rapidphp for edit & change code.

In the HTTP protocol a server response consists of a group of headers followed by a body, separated by a single blank line (i.e. a line containing only a carriage-return). This warning message is produced by PHP if a program attempts to send an additional HTTP header after the separator (and hence all the headers) has already been sent.

By far the most common cause of this problem is that one or more PHP files contains characters (usually a space or an empty line) outside of the <?php and ?> tags. To fix the problem you should examine the PHP file indicated in the warning message and remove any blank characters at the beginning and end of the file. Some text editors, including some online file managers, are prone to automatically adding extraneous line-ending characters at the ends of files, particularly when not configured to do otherwise.

Remove the closing ?> tag at the end of your PHP files. It actually serves no useful purpose as the PHP interpreter knows that end-of-file means end-of-PHP too. Removing it means that any extra blank characters added by your editor will have no effect on the output generated and so will not prevent additional HTTP headers from being sent.

Turn output_buffering setting on php.ini to on to permanently remove this error

commented: Learn what to say before replying, dont reply to threads marked SOLVED, read the instructions -3

Thanx a lot JeniF...

Your suggesion helps me...

can anyone help me? I'm with a problem to activate the plugin wp-postratings on my site. When I activate the plugin, the following error appears:

"Warning: Cannot modify header information - headers already sent by (output started at /home/universc/public_html/wp-content/plugins/wp-postratings/wp-postratings.php:2635) in /home/universc/public_html/wp-includes/pluggable.php on line 866"

how to solve this?

the thread is ol bud i'd like to share my persolnal solution. I got the (Warning: Cannot modify header information - headers already sent by) warning working with dotproject application and I read elsewhere that the bug may be empy spaces in the bottom os php code file. Tried to clean empty spaces and everything else and nothing. After call a friend to help he discovered some few blank characters in the end of php file code that was generating html undesirable code and therefore the warning..... hard to track "invisible" bugs like that.... best regards to all.

Fantastic, I was amazed and so relieved. My problem was refreshing the same page of listed results immediately after deleting one of them with a Form submit and this solution is the only one that works. Truely many thanks. Peter

<? ob_start(); ?>

<? ob_flush(); ?>

thanks jenif. it worked perfectly.

How do I fix the issue if I can't even log in as an admin?

Thank you Jeni and Jessie! This code and no extra spaces solved it!
Blessings,
Tadej

Thanks JeniF...your suggestions just worked like magic.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.