If you've got a problem with a script read through this topic again, check the php manual, and post in the normal forum if you're still having trouble.wmasterj wrote:i don't know why but that ob_*() stuff has never worked for me!
oh well!
Warning: Cannot add header information
Moderator: General Moderators
-
[xNet]DrDre
- Forum Newbie
- Posts: 8
- Joined: Wed Oct 01, 2003 7:06 am
there is one way to disable this error!
Now you can send text before headers and not get an error, such as cookies, this now would be valid
Code: Select all
<?
@ini_set("output_buffering","On");
?>Code: Select all
You are now logged in!<? setcookie('LoggedIn','true',time()+3600);?>
This is what I have been utilizing recently.
Code: Select all
<?php
ob_start();
if(!headers_sent()) {
header("refresh: 1; url=http://www.example.com");
}
ob_end_flush();
?>
Last edited by Benjamin on Mon May 11, 2009 2:10 am, edited 1 time in total.
Reason: Changed [code] to [code=php]
Reason: Changed [code] to [code=php]
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Still on Variables
Thanks, your solution works for header() but i still have problem with the session variable 
Re: ob_start in relation to cookies
moniarde wrote:Hope that helps.Code: Select all
<?php ob_start(); ?> <html> <body> <?php echo "testing 1,2,..."; setcookie("testcookie", "test"); ?> </body> </html>![]()
I am wondering how about show cookie?? can ar?
Re: Warning: Cannot add header information
I've fixed the code formatting in this post and resurrected it from the grave. We get this question a lot around here, so keep in mind where this post is so you can refer to it whenever this question arises.