Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Headers alreay sent

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Mon Jul 30, 2007 8:59 am    Post subject: Headers alreay sent Reply with quote

Hi,

I have a problem with my header() function. It doesn't work.
Code:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/faq/templates_c/%%45^45E^45E480CD%%index.tpl.php:11) in /var/www/faq/public_html/article.php on line 10


where line 11 in index.tpl.php is:
Code:
<meta name="description" content="Welkom op de website van Faith Answers & Questions.">


and line 10 in article.php is:
Code:
header('Location: index.php');


I don't understand what is wrong. Can anybody help me?

Thanks

Alex
Back to top
View user's profile Send private message Send e-mail
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Mon Jul 30, 2007 9:08 am    Post subject: Reply with quote

You may not have sent anything to the client before the header() statement. So it must be before any echo command or smarty->display().
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Mon Jul 30, 2007 9:51 am    Post subject: Reply with quote

Celeb wrote:
You may not have sent anything to the client before the header() statement. So it must be before any echo command or smarty->display().
I know that something was sent prior to the header(), but I don't know what?! I cannot be the <meta name> that is for sure!
Back to top
View user's profile Send private message Send e-mail
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Mon Jul 30, 2007 10:36 am    Post subject: Reply with quote

Why is that so sure? PHP seems to disagree with you on that point. What else would you want to do with that line other than sending it to the client?
Maybe you can posat some more code than these two lines so we have a chance of spotting the problem.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Mon Jul 30, 2007 10:56 am    Post subject: Reply with quote

Celeb wrote:
Maybe you can post some more code than these two lines so we have a chance of spotting the problem.
I will, thanks. But it will be tonight when i'm at home.

Gr. Alex
Back to top
View user's profile Send private message Send e-mail
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Mon Jul 30, 2007 7:05 pm    Post subject: Reply with quote

I figured it out. I forgot to enter:
Code:
ob_start();

on top of the page. Once I did that everything worked fine!

Thankx,

Alexander
Back to top
View user's profile Send private message Send e-mail
chrisjenx2001
Smarty Rookie


Joined: 19 Nov 2007
Posts: 6

PostPosted: Tue Nov 27, 2007 6:42 pm    Post subject: Reply with quote

I have to say that ob_start(); fixed about 10 problems i was having lol.

I'm super happy now!!
Back to top
View user's profile Send private message
master_kaos
Smarty Regular


Joined: 02 Aug 2007
Posts: 54

PostPosted: Tue Nov 27, 2007 7:06 pm    Post subject: Reply with quote

a common problem to this is u may have 1 space or 1 enter key before a <?php tag which counts as output
Back to top
View user's profile Send private message
chrisjenx2001
Smarty Rookie


Joined: 19 Nov 2007
Posts: 6

PostPosted: Tue Nov 27, 2007 8:24 pm    Post subject: Reply with quote

This is alittle beyond headers but it seems to be causeing the problem.

Code:

  function login ($params,&$smarty){
   $this->login_f($params['username'],$params['password'],$login_error,$logerror){
   $smarty->assign('login_msg',$login_error);
   $smarty->assign('logerror',$logerror);
   header("location: index.php?action=loginerror&register_user=on");
   
  }


i take it the $smarty-assign are never handed back because before it can complete the function the script is redirected?

is that so? as if i remove the header statment the values are returned.
is there anyway to hand the results back to the page i redirect to?
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Wed Nov 28, 2007 11:09 am    Post subject: Reply with quote

Use Session variables (server side) or the Querystring (take roundtrip to the client = security critical) of the page you redirect to.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP