Jump to content


Photo

I did read the pinned note about headers, but...


  • Please log in to reply
16 replies to this topic

#1 TecBrat

TecBrat
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 15 July 2006 - 12:34 AM

I am incoporating an existing script into my site. The problem I am having is that their script is sending headers. (My novice skills barely understand what that means.) What I've done is where I usually include my own content, I have an if (!foo='' || !bar=''){ their_code(); } where foo and bar as well as others like them are the variables I found that it uses.
Their script had a selection to disable a header warning. I selected that. Then I get to another part of the application that includes an email form. I submit the form, and the email is sent. (I received it) but the page gives a header already sent error.
I can supress the error by putting @ in front of the function they use to call their whole program, But any code I put after the dying function is not executed. I tried using or die() and it did not work either. I tried putting ob_flush(); right before their function, but I still got the error. (I had never heard of ob_flush before I read that pinned note.)
Any ideas?
The only thing I need to do after it dies is give the user a message and send them back to the home page.
It's kinda lame at the moment, but...
PHP MySQL Playground

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 15 July 2006 - 12:43 AM

We need to see more code.

Ken

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 12:44 AM

what about adding a if statement.

//a varable holds data if it's there send them somewere.
if($whatever="what_ever") {

header("location: whatever.com");

}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 12:50 AM

just put the following code at the very top i promise it make the headers work anywhere
<?php
ob_start();
?>


#5 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 12:51 AM

i realize i suggested using output buffering (very unclearly) in my pinned topic, but that DOES NOT FIX THE HABIT THAT FORMS THESE ERRORS.

billybob, please stop recommending this as a solution to everyone's header issues.

tecbrat:  i'd like to start by saying thank you for reading the pinned topic, however unhelpful it is (i posted it a LONG time ago).  as ken said, we'd need to see your code to get an idea of how to fix the issue in this instance..

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 12:57 AM

akitchin would a if statement make any diffrence mate.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 01:11 AM

it works so just use it and we will have them stoped whinning right?

#8 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 01:24 AM

billybob:  this forum is NOT about "have them stoped whinning," it's about solving problems, and hopefully in such a way that the problem is avoided in the future.  i've edited my pinned topic to be clearer and more descriptive.  read it again and maybe you won't have to use ob_start() in the future yourself.

redarrow:  i'm not sure he's in a spot to know where to put that if(), and whether it would work.  we need to see more code to know what he's dealing with.

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 01:29 AM

akitchin i read the new post thanks very nice cheers.


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 15 July 2006 - 01:37 AM

Post the code and we'll see if anything is being output before the new headers.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#11 TecBrat

TecBrat
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 15 July 2006 - 02:55 AM

WOW! That was a lot of replies in a hurry.
This worked. I found a solution that did not send another header.
Most of my problems stem from using other people's code, and not knowing what they were doing.
	?>
	<meta http-equiv="refresh" content="0; url=<?echo($url);?>">
	<?
	//header('Location: ' . $url);


It's kinda lame at the moment, but...
PHP MySQL Playground

#12 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 03:06 AM

um i use cookies for login and thats how to set them up how do u make the user stay loged in

#13 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 03:08 AM

just put the following code at the very top i promise it make the headers work anywhere

<?php
ob_start();
?>

Lol, it makes me laugh that you always suggest output buffering and everyone says not to use it. XD

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#14 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 03:13 AM

billybob, what are you talking about?

#15 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 03:27 AM

im saying how do u make the user login

so that u dont have to use the dredful ob_start();

#16 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 03:49 AM

read my pinned topic, it has been changed to be clearer.  if you still have troubles understanding, post a new topic.

#17 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 03:50 AM

im saying how do u make the user login

so that u dont have to use the dredful ob_start();

Just put session_start(); at the top of the page. Ditch the cookies, and use sessions. They're more secure anyways.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users