include_once('session.php');
include_once('config.php');
$userid = $_SESSION['userid'] ;
$uname = $_GET['uname'];
 $query= "call sp_active('$uname','$userid',@u_active)";

$result = mysql_query($query) or die('query_error'.''.mysql_error());
  if($result)
  {
    header('location:vagent.php');
  }

simple php code.. but still throwing Cannot modify header information - headers already sent by

i have also use ob_start(); but of no use

Recommended Answers

All 4 Replies

There may be something in session.php or config.php that adds spaces to the output (or more).

include_once('session.php');
include_once('config.php');
$userid = $_SESSION['userid'] ;
$uname = $_GET['uname'];
 $query= "call sp_active('$uname','$userid',@u_active)";

$result = mysql_query($query) or die('query_error'.''.mysql_error());
  if($result)
  {
    header('location:vagent.php');
  }

simple php code.. but still throwing Cannot modify header information - headers already sent by

i have also use ob_start(); but of no use

I take it you are also using ob_end_flush() at the end?

include_once('session.php');
include_once('config.php');
$userid = $_SESSION['userid'] ;
$uname = $_GET['uname'];
 $query= "call sp_active('$uname','$userid',@u_active)";

$result = mysql_query($query) or die('query_error'.''.mysql_error());
  if($result)
  {
    header('location:vagent.php');
  }

simple php code.. but still throwing Cannot modify header information - headers already sent by

i have also use ob_start(); but of no use

Are you using ob_start() before any PHP code?

eg:

<?php
ob_start();
 include_once('session.php');
include_once('config.php');
// .. etc...
?>

Also make sure there isn't any spaces or newlines before the call to ob_start();

The other possible problems is if you have a UTF BOM added by your editor, if you're using windows.
http://en.wikipedia.org/wiki/Byte_order_mark

You can detect this with PHP by making a HTTP request (eg: file_get_contents()) to the page, and checking if the first byte matches unicode point U+FEFF.

Another possibility is if you have errors in your PHP build, or configuration, that makes it spit out an error before PHP scripts are interpreted.

Both of these would cause header() to fail even if ob_start() is used since they occur before any PHP code you write.

i dont know that spaces also create problem in header..!!
anyways thanks for reply

problem solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.