Page 1 of 1
Cannot add header information error
Posted: Tue Apr 01, 2003 11:39 pm
by tiendan
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
Posted: Tue Apr 01, 2003 11:43 pm
by phice
page1.php:
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"
?>
Always have
session_start(); at the very beginning of any php file that uses sessions.

Posted: Wed Apr 02, 2003 4:18 am
by tiendan
Thank for your help
phice wrote:page1.php:
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"
?>
Always have
session_start(); at the very beginning of any php file that uses sessions.

Posted: Wed Apr 02, 2003 4:25 am
by tiendan
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.
Posted: Wed Apr 02, 2003 4:47 am
by volka
the error occured in page2.php but you gave us page1.php. If it also starts with
<?
include "config.inc";
make sure
< is the very first character in that file. No whitespace, no single linebreak, nothing(!) before that.
Posted: Wed Apr 02, 2003 5:23 am
by tiendan
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.
Posted: Wed Apr 02, 2003 6:03 am
by volka
the there must be something in page2.php@line 1.
php is usually right about that
Code: Select all
<?php /** file: i2.php */ echo 'content'; ?>
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.
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()
*/
?>
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
the location is almost always accurate. You should focus your search there.
Posted: Wed Apr 02, 2003 9:53 pm
by tiendan
OOK
I fixed this problem. On the local server no problem, no space in the page1.php but when I upload to server, space add to page1.php ---> error. I have to fix it on server. It OK.
PHP very annoyance.
Thank Mr Volka
Posted: Thu Apr 03, 2003 1:28 am
by twigletmac
tiendan wrote:On the local server no problem, no space in the page1.php but when I upload to server, space add to page1.php ---> error. I have to fix it on server. It OK.
PHP very annoyance.
I would have said FTP client very annoyance...
Mac