Author Topic: godaddy header problem  (Read 634 times)

0 Members and 1 Guest are viewing this topic.

Offline RiftsTopic starter

  • Devotee
  • Posts: 612
  • Gender: Male
    • View Profile
godaddy header problem
« on: March 18, 2010, 10:36:34 PM »
hey everyone.

i'm getting this error:
Code: [Select]
Warning: Cannot modify header information - headers already sent by
i know its because the code is not the first line but there is no way for it to be on the first line because the code has this:
if ($check == 1)
	
   {
	
     
header("location: domainform.php");
	
	
 }
	
	
 Else {
	
	
 
header("location: payment.php");
	
	
 }


so is there anyway to redirect someone with php without useing header?

Offline RiftsTopic starter

  • Devotee
  • Posts: 612
  • Gender: Male
    • View Profile
Re: godaddy header problem
« Reply #1 on: March 18, 2010, 10:38:45 PM »
well i figured it out if anyone else has this problem just add this
ob_start();
	
  if (
$check == 1)
	
   {
	
     
header("location: domainform.php");
	
	
 }
	
	
 Else {
	
	
 
header("location: payment.php");
	
	
 }
	
	
 
ob_flush();


Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: godaddy header problem
« Reply #2 on: March 19, 2010, 12:27:01 AM »
That is a hack. You should fix your code so no output is sent prior to redirecting.

Offline RiftsTopic starter

  • Devotee
  • Posts: 612
  • Gender: Male
    • View Profile
Re: godaddy header problem
« Reply #3 on: March 19, 2010, 09:07:13 PM »
how do i fix it

Offline DavidAM

  • Devotee
  • Posts: 1,026
  • Gender: Male
    • View Profile
Re: godaddy header problem
« Reply #4 on: March 19, 2010, 09:29:42 PM »
The error message does not mean that the header() function must be the first line of code.  It just has to be executed before any output is sent (to the browser).  Output is sent when you call echo, print() or other functions that send information.  If an error occurs and error_reporting is on, errors are sent to the browser.  Anything, ANYTHING including blank lines or spaces that are outside of the php tags (<?php ... ?>  or  <? ... ?>) is automatically sent to the browser.

Check everything above the code that is calling the header() function.  Also check all included files.  One common cause is when there is a line-feed (or carriage-return) after the last closing tag "?>" in an included file.  A common solution to this, is to just not include the closing tag in the included files.  You'll have to decide for yourself whether that is a hack or not.

Also make sure there is NOTHING BEFORE the first opening php tag.
-- I haven't lost my mind, it's backed up on tape ... somewhere!