halm1985 Posted August 8, 2007 Share Posted August 8, 2007 Why is the following error always displayed on my browswer when i use HEADER() function ? Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\Applications\Guest_Book\admin.php:10) in C:\wamp\www\Applications\basic.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/ Share on other sites More sharing options...
flappy_warbucks Posted August 8, 2007 Share Posted August 8, 2007 Becuase there has been an output to the page before (such as an error) but if *anything* is sent to the browser then the header function wont work for example: echo "hello"; header("Location: somepage.php"); that wont work,. however this will: header("Location: somepage.php"); the reason is that php has sent out the headers already, and it cannto do it again. Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318396 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Share Posted August 8, 2007 If you use the ob_start(); function at the top of your page you can output headers even if information has been sent to the browser ! Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318401 Share on other sites More sharing options...
halm1985 Posted August 8, 2007 Author Share Posted August 8, 2007 ok, but the problem still exists here's the case i have the following defined function in header.php file <?php # AUTENTICATE function authenticate($realm = "WBGRS", $errmsg) { header("WWW-Authenticate : Basic realm = \"$realm\""); header("HTTP/1.0 401 Unauthorized"); die ($errmsg); } and i need to call this function after including this HEADER.PHP page in another one ?? how can that be done ?? ABOUT THE OBSTART() function .. it didn't work .. what should the supplied arguments be ? Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318421 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Share Posted August 8, 2007 not OBSTART(); ob_start(); it is called output buffering. Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318424 Share on other sites More sharing options...
halm1985 Posted August 8, 2007 Author Share Posted August 8, 2007 yeah .. i typed it ob_start() .. i just put it this way here .. Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318426 Share on other sites More sharing options...
Guardian-Mage Posted August 8, 2007 Share Posted August 8, 2007 go to php.net and search for the function. It gives a nice description of how to use it. Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318427 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Share Posted August 8, 2007 Well, I don't see why it wouldn't work, unless your hosting provider has disabled it ??? Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318429 Share on other sites More sharing options...
halm1985 Posted August 8, 2007 Author Share Posted August 8, 2007 I'm working on a local host .. "WAMP" architicture Quote Link to comment https://forums.phpfreaks.com/topic/63880-header-functino-failure/#findComment-318441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.