# Warning: Cannot modify header information - headers already sent by (output started a

**URL:** <https://forum.kirupa.com/t/warning-cannot-modify-header-information-headers-already-sent-by-output-started-a/229708>\
**Category:** programming\
**Created:** [June 19, 2007, 4:52pm UTC](https://forum.kirupa.com/t/warning-cannot-modify-header-information-headers-already-sent-by-output-started-a/229708 "2007-06-19T16:52:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitin\_2k1](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@nitin\_2k1](https://forum.kirupa.com/u/nitin_2k1)\
**Post date:** [June 19, 2007, 4:52pm UTC](https://forum.kirupa.com/t/warning-cannot-modify-header-information-headers-already-sent-by-output-started-a/229708/1 "2007-06-19T16:52:19Z")

</div>

i am getting this error in my php script can anyone help?

**Warning** : Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\Connections\hi.php:12) in **c:\program files\easyphp1-8\www\sign up.php** on line \*\*38

and line 38 is this  
-----header("Location: ". $MM\_redirectLoginSuccess );

my code in php is below  
\<?php  
// \*\*\* Validate request to login to this site.  
if (!isset($\_SESSION)) {  
session\_start();  
}

$loginFormAction = $\_SERVER[‘PHP\_SELF’];  
if (isset($\_GET[‘accesscheck’])) {  
$\_SESSION[‘PrevUrl’] = $\_GET[‘accesscheck’];  
}

if (isset($\_POST[‘user\_type’])) {  
$loginUsername=$\_POST[‘user\_type’];  
$password=$\_POST[‘user\_password’];  
$MM\_fldUserAuthorization = “”;  
$MM\_redirectLoginSuccess = “67Microsoft Word - kebabs.pdf”;  
$MM\_redirectLoginFailed = “Sign Up.php”;  
$MM\_redirecttoReferrer = true;  
?\>  
\<?php require\_once(‘Connections/hi.php’); ?\>

\<? mysql\_select\_db($database\_hi, $hi);  
$LoginRS\_\_query=sprintf(“SELECT user\_type, user\_password FROM userrecords WHERE user\_type=’%s’ AND user\_password=’%s’”,  
get\_magic\_quotes\_gpc() ? $loginUsername : addslashes($loginUsername), get\_magic\_quotes\_gpc() ? $password : addslashes($password));

$LoginRS = mysql\_query($LoginRS\_\_query, $hi) or die(mysql\_error());  
$loginFoundUser = mysql\_num\_rows($LoginRS);  
if ($loginFoundUser) {  
$loginStrGroup = “”;

```
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;          

if (isset($_SESSION['PrevUrl']) && true) {
  $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
}
header("Location: ". $MM_redirectLoginSuccess );

```

}  
else {  
header("Location: ". $MM\_redirectLoginFailed );  
}  
}  
?\>  
\*\*

---

<div class="post-metadata">

**Author:** ![xjessie007](https://avatars.discourse-cdn.com/v4/letter/x/977dab/32.png) [@xjessie007](https://forum.kirupa.com/u/xjessie007)\
**Post date:** [May 19, 2008, 6:37pm UTC](https://forum.kirupa.com/t/warning-cannot-modify-header-information-headers-already-sent-by-output-started-a/229708/2 "2008-05-19T18:37:30Z")

</div>

I had a problem with the “headers already sent” too at my [**[COLOR=blue]http://www.Maxi-Pedia.com[/COLOR]**](http://www.Maxi-Pedia.com) website. In my case, it was caused by a blank line at the beginning of one \*.inc file. PHP seems to have problems with extra spaces here and there.

Check all your \*.inc files to make sure you do not have closing ?\> in any of them. Closing ?\> is not needed in your \*.inc files. Check all your \*.php files to make sure you do not have blank lines at the beginning or at the end.

If you are working in a CMS, then it may be caused by some module, disable your modules one by one to find out which one causes this.

This can also be caused by UTF-8. If you have your website coded in ASCII and are saving your php files as UTF-8, it can cause this message. If your website and DB are UTF-8, you should be ok with saving php files as UTF-8 though.

Btw, this error message is related to \<b\>output\_buffering\</b\> on/off in your php.ini. If you have output\_buffering set to some cache, the server will allow to send headers with delay (or to modify them shortly after they are sent), and this error will not be tripped. But if you set output\_buffering to 0 or not at all, then headers can be sent at only one moment, and if you have some bad code, it will trip this error message.
