Forum Moderators: coopster

Message Too Old, No Replies

Php Headers Sent Already Errors

         

xxshadowxx

11:05 pm on Sep 7, 2007 (gmt 0)

10+ Year Member



When I take out the include, it works strangely.






<?php
include('header.php');

mysql_connect ('localhost', '', '') ;
mysql_select_db ('thunder_cms');

if (isset($_POST['update'])) {

$id = htmlspecialchars(strip_tags($_POST['id']));
$month = htmlspecialchars(strip_tags($_POST['month']));
$date = htmlspecialchars(strip_tags($_POST['date']));
$year = htmlspecialchars(strip_tags($_POST['year']));
$time = htmlspecialchars(strip_tags($_POST['time']));
$entry = $_POST['entry'];
$title = htmlspecialchars(strip_tags($_POST['title']));
if (isset($_POST['password'])) $password = htmlspecialchars(strip_tags($_POST['password']));
else $password = "";

$entry = nl2br($entry);
$category = (int)$_POST['category'];

if (!get_magic_quotes_gpc()) {
$title = addslashes($title);
$entry = addslashes($entry);
}

$timestamp = strtotime ($month . " " . $date . " " . $year . " " . $time);

$result = mysql_query("UPDATE php_blog SET timestamp='$timestamp', title='$title', entry='$entry', password='$password', category='$category' WHERE id='$id' LIMIT 1") or print ("Can't update entry.<br />" . mysql_error());

header("Location: /journal.php?id=" . $id);

}

[edited by: eelixduppy at 11:44 pm (utc) on Sep. 7, 2007]
[edit reason] removed specifics and code dump [/edit]

xxshadowxx

11:08 pm on Sep 7, 2007 (gmt 0)

10+ Year Member



sorry, i meant it works if u take out the include, but doesnt it work if u put in the includes.

the error is

Warning: Cannot modify header information - headers already sent by (output started at /home/thunder/public_html/cms/admin/header.php:7) in /home/thunder/public_html/cms/admin/update.php on line 28

eelixduppy

11:48 pm on Sep 7, 2007 (gmt 0)



What do you have in the header.php file? If there is any output from that file, or if there are whitespace characters, etc, being sent to the browser the header() function will not work correctly. Depending on whether or not you need that include there, it should be moved until AFTER the header() function.