Headers allready sent issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Headers allready sent issue

Post by Jim_Bo »

Hi, I have inserted the following code into the header page of the script:

Code: Select all

<?php ob_start(); session_start(); header("Cache-control: private"); ?>
followed by the rest if the code ie:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 

xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" 

content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" 

href="http://www.whatever.com/templates/style/site.css" />
<title><?php .......
I thought that ob_start() would clear the problem.

Any ideas, its been created in notepad.


Thanks
Last edited by Jim_Bo on Mon Mar 06, 2006 11:04 pm, edited 1 time in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Hello,

The has to be a space before your first <?php before ob_start();

Get rid of that and it will work.
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi have backspaced 100 times .. there is no whitespace presant that can be seen .. I have tried in notepad and dreamweaver ..

after trying to login i get:

Code: Select all

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/###/public_html/###/upload.html:753) in /home/fusion/public_html/###/templates/header.html on line 1
but prior to logging in its fine ..

Thanks
Last edited by Jim_Bo on Mon Mar 06, 2006 11:12 pm, edited 1 time in total.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Here and for other refrence.

Read Jasons tutorial on the header function (it is based on that error).
:arrow: viewtopic.php?t=1157
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Yer I got a pretty good understanding how it works .. and i also know that ob_start normally fixes the the problem in this case.

I am 100% sure that there are no whitespaces unless they are hidden or something strange like that ..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: the error tells you where the output started that caused it to happen.
Post Reply