-3

The following code is not working even after having inserted ob_start(), and ob_flush();

I keep getting the PHP headers already sent error

<?php 
ob_start();
include("/home/www/pheincl/config.php");
include("/home/www/pheincl/common_functions.php");
$num = $_SERVER['HTTP_X_UP_CALLING_LINE_ID'];

if($num == null)
{
  $num = $_SERVER['HTTP_X_MSISDN'];

  if($num == null)
  {
    $num = $_GET["msisdn"];

  }
}

if(strlen($num) > 3)   
{
  $sql="select count(*) from members where msisdn='$num'";
  $r=fetch($sql);

  if($r[0] > 0)
  {
    $r1=fetch("select pin from members where msisdn='$num'");

    if(strlen($r1[pin]) > 2)
    {
      header("Location:http://location1.com?msisdn=$num&pin=$r1[pin]");
    }
  }
  else
  {
    header("Location:http://location2.com&msisdn=$num");
  }   
}
else 
{
  header("Location:location3.com/phe/log.php");
}

ob_end_flush();
?>

UPDATE: After some further testing it looks like this problem is specific to my servier. Someone I know put this on their server and it worked fine

Michael Farah
  • 325
  • 1
  • 7
  • 20

4 Answers4

4

use notepad++ and set encoding to UTF8 without BOM your BOM (Byte Order Mark) is probably what's causing it

EDIT: Make sure you do it on all included files

galchen
  • 5,252
  • 3
  • 29
  • 43
1

Before any header function, the script shouldn't print anything. That means no echo, no html code outside php tags etc.

So either that sql echoes some error, or your include files do something similar.

George Kastrinis
  • 4,924
  • 4
  • 29
  • 46
0

Something is sending some output to the browser before your header code executes. Look for any errors output to the screen or any print or echo statements.

ghostJago
  • 3,381
  • 5
  • 36
  • 51
-1

You can try to delete the final ?> to avoid the problem. Sometimes this fixes the problem.