You are here: Re: HEADERS Already sent (NewBie question) « PHP Programming Language « IT news, forums, messages
Re: HEADERS Already sent (NewBie question)

Posted by Alistair Baillie SS2002 on 05/13/05 14:06

As the errors say, headers already sent.

This means that you have already tried to send text, or something to the
browser, either using an echo, or print statement.

Also check your code, to make sure you have NO whitespace outside the PHP
tags, otherwise this will cause apache to send the whitespace, therefore
removing your ability to set headers.

Headers, as the name suggests must be sent BEFORE you can send any data to
be displayed.

- Ali*


"Angelos" <angelos@redcatmedia.net> wrote in message
news:d61uaf$nfd$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
> Hello again... I was wondering is there any way to check or output in the
> errors string which file or where in my code the headers have been sent ?
>
> I am trying to use this script
> *******************************************************************************************
> function redirect($url) {
> if(!headers_sent()) {
> header('Location: http://'.$_SERVER['HTTP_HOST'] .
> dirname($_SERVER 'PHP_SELF']) . '/' . $url);
> }
> else {
> die('Could not redirect; Headers already sent.');
> }
> }
> *********************************************************************************************
> But no luck in some redirect attempts. It works in some files but I can't
> figure out when it doesn't work.
>
> bellow is a part of the code that it doesn't work
> ***************************************************************************
> <? require_once 'http.php'; ?> <====HEre is the Redirection Function
> <?php require_once('db_conn.php'); ?>
> <? session_start(); ?><? header("Cache-control: private"); // IE 6 Fix.
> ?>
> <?
>
>
> if (isset($_REQUEST['contcat']) && isset($_REQUEST['action'])) {
> switch ($_REQUEST['contcat']) {
> case 'content':
> switch ($_REQUEST['action']) {
> case 'add_webpage':
> printf (($_POST['title']) . ($_POST['Contentbody']) .
> ($_SESSION['user_id']));
> if (isset($_POST['title']) and
> isset($_POST['Contentbody']) and isset($_SESSION['user_id'])) {
> mysql_select_db($db, $db);
> $sql = "INSERT INTO bla bla bla";
> mysql_query($sql, $db) or die('Could not
> content'.mysql_error());
> }
> redirect('index.php'); <<<<<=================
> break;
> default:
> break;
> }
> default:
> break;
> }
> }
> ***************************************************************************
> I would really appreciate some help.
> Thanks Angelos.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация