Cannot add header information error
Moderator: General Moderators
Cannot add header information error
Admin Edit: Moved from the 'Cannot add header information' sticky.
I have code PHP in 3 file :
page1.php
----------------------
<?
include "config.inc";
session_start();
session_register("sess_var");
$sess_var="Hello world";
echo "The content of \$sess_var is $sess_var<br>";
include "end.inc"
?>
----------------------
config.inc
----------------
<?
ob_start();
?>
----------------
end.inc
--------------
<?
ob_end_flush();
?>
--------------------
My computer installed PHP 4.3, but on server installed PHP 4.2 . And this code run with no error on my computer but on the server have error.
This error is "Warning: Cannot send session cache limiter - headers already sent (output started at /home/phptutor/public_html/page2.php:1) in /home/phptutor/public_html/page2.php on line 1
"
Can everybody help me. Thank you
I have code PHP in 3 file :
page1.php
----------------------
<?
include "config.inc";
session_start();
session_register("sess_var");
$sess_var="Hello world";
echo "The content of \$sess_var is $sess_var<br>";
include "end.inc"
?>
----------------------
config.inc
----------------
<?
ob_start();
?>
----------------
end.inc
--------------
<?
ob_end_flush();
?>
--------------------
My computer installed PHP 4.3, but on server installed PHP 4.2 . And this code run with no error on my computer but on the server have error.
This error is "Warning: Cannot send session cache limiter - headers already sent (output started at /home/phptutor/public_html/page2.php:1) in /home/phptutor/public_html/page2.php on line 1
"
Can everybody help me. Thank you
page1.php:
Always have session_start(); at the very beginning of any php file that uses sessions. 
Code: Select all
<?
session_start();
include "config.inc";
session_register("sess_var");
$sess_var="Hello world";
echo "The content of \$sess_var is $sess_var<br>";
include "end.inc"
?>Thank for your help
phice wrote:page1.php:Always have session_start(); at the very beginning of any php file that uses sessions.Code: Select all
<? session_start(); include "config.inc"; session_register("sess_var"); $sess_var="Hello world"; echo "The content of \$sess_var is $sess_var<br>"; include "end.inc" ?>
Yes, I have make seem you
<?
session_start();
include "config.inc";
session_register("sess_var");
$sess_var="Hello world";
echo "The content of \$sess_var is $sess_var<br>";
include "end.inc"
?>
but still notice error.
The Attribute output_buffering =novalue. I think this attribute is cause of problem but I can not fix it.
File config.ini
------------
<?
ob_start();
ini_set('session.use_trans_sid', false);
ini_set('session.use_cookies',false);
ini_set('output_buffering',4096);
?>
Please help me.
<?
session_start();
include "config.inc";
session_register("sess_var");
$sess_var="Hello world";
echo "The content of \$sess_var is $sess_var<br>";
include "end.inc"
?>
but still notice error.
The Attribute output_buffering =novalue. I think this attribute is cause of problem but I can not fix it.
File config.ini
------------
<?
ob_start();
ini_set('session.use_trans_sid', false);
ini_set('session.use_cookies',false);
ini_set('output_buffering',4096);
?>
Please help me.
Yes I know, . No whitespace, no single linebreak, nothing(!) before session_start() function.
This code is good run on my computer and not have any error, but when I upload to server and run program --> have error.
Php.ini on local
output_buffering =4096;
If I change this attribute = novalue ---> have error.
I don't understant this.
This code is good run on my computer and not have any error, but when I upload to server and run program --> have error.
Php.ini on local
output_buffering =4096;
If I change this attribute = novalue ---> have error.
I don't understant this.
the there must be something in page2.php@line 1.
php is usually right about that
php.ini: auto_prepend_file = /path/to/i1.php
error, because i1.php has a linebreak before the starting tag, no session_start() using cookies will ever work without output buffering.
php is usually right about that
Code: Select all
<?php
// file: i1.php
$i = 2;
?>Code: Select all
<?php /** file: i2.php */ echo 'content'; ?>Code: Select all
<?php
// file: i3.php
$i = 3;
?>Code: Select all
<?php
include('i2.php');
session_start(); // also not working, echo 'content'; is already executed
?>Code: Select all
<?php
include('i3.php');
session_start();
/**
doesn't work either, because i3.php has some blank lines at the end that have been sent to the client before session_start()
*/
?>the location is almost always accurate. You should focus your search there.Warning: Cannot send session cache limiter - headers already sent (output started at /home/phptutor/public_html/page2.php:1) in /home/phptutor/public_html/page2.php on line 1
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
