cannot seem to use both include nad header functions togethe
Moderator: General Moderators
cannot seem to use both include nad header functions togethe
Hi all;
This is a real basic one; the problem seems to be that I cannot use the include and header function together.
When I use the header function to send my clients to the page called main.php (by the way main.php has three include files and one of them which is a variable defined from the page before) I get the following error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\respondnow\main.php:8) in C:\Program Files\Apache Group\Apache2\htdocs\respondnow\editevent.php on line 56
Now i know that Im getting this error because of the include and header items being used together I just cant seem to sort it out or find some other information regarding how to fix or work around it.?????
THanks all, any help is appreciated.
This is a real basic one; the problem seems to be that I cannot use the include and header function together.
When I use the header function to send my clients to the page called main.php (by the way main.php has three include files and one of them which is a variable defined from the page before) I get the following error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\respondnow\main.php:8) in C:\Program Files\Apache Group\Apache2\htdocs\respondnow\editevent.php on line 56
Now i know that Im getting this error because of the include and header items being used together I just cant seem to sort it out or find some other information regarding how to fix or work around it.?????
THanks all, any help is appreciated.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Warning: Cannot add header information
a lovely tutorial on what's wrong and how to fix it, written by our very own people.
please search next time, thanks.
a lovely tutorial on what's wrong and how to fix it, written by our very own people.
please search next time, thanks.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
If you're putting your include() somewhere before the header() then you'll get that error.
header() cannot be used anywhere on a page after anything has been sent for output (that includes whitespace such as line breaks).
Check if your header is being sent anywhere after such includes or printed content in the whole scale of things and then you should see it.
header() cannot be used anywhere on a page after anything has been sent for output (that includes whitespace such as line breaks).
Check if your header is being sent anywhere after such includes or printed content in the whole scale of things and then you should see it.
my includes are on another page
thanks feyd for the quick response but when i use the buffer output cleaner it tells me that there is: No buffer to delete or flush
Now I'm not to sure if i used it correctly, but i just placed it at the end of my php statement(it seems like it's pretty easy to use)
d11wtq, i have included the pages php code that i'm referencing so you can see what I'm talking about this is refenced when the btton is pushed to execute the php code:
and here's the error i get
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\respondnow\main.php:8) in C:\Program Files\Apache Group\Apache2\htdocs\respondnow\editevent.php on line 55
the thing is when i use framesets to send the clients around I dont get a problem with the header function; as soon as I started using main.php which has the include statements
the php code for main.php is as follows:
like i said when i use this code i get the header function im convinced its got to do with me using include nad headers simultaneously
thanks again all
feyd | Help us, help you. Please use
Now I'm not to sure if i used it correctly, but i just placed it at the end of my php statement(it seems like it's pretty easy to use)
d11wtq, i have included the pages php code that i'm referencing so you can see what I'm talking about this is refenced when the btton is pushed to execute the php code:
Code: Select all
<?php
<?php require_once('Connections/RespondNow.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE events SET Name=%s, Adress=%s, Venue=%s, `Date`=%s, `Time`=%s, Description=%s, TemplateType=%s, MaxSeats=%s, Sponsor=%s, `Map`=%s WHERE ID=%s",
GetSQLValueString($_POST['txtEventName'], "text"),
GetSQLValueString($_POST['txtAdress'], "text"),
GetSQLValueString($_POST['txtVenue'], "text"),
GetSQLValueString($_POST['txtDate'], "text"),
GetSQLValueString($_POST['txtTime'], "text"),
GetSQLValueString($_POST['txtInviteCopy'], "text"),
GetSQLValueString($_POST['ddlEventType'], "text"),
GetSQLValueString($_POST['txtMaxReg'], "text"),
GetSQLValueString($_POST['txtSponsor'], "text"),
GetSQLValueString($_POST['txtMap'], "text"),
GetSQLValueString($_POST['hiddenRecID'], "int"));
mysql_select_db($database_RespondNow, $RespondNow);
$Result1 = mysql_query($updateSQL, $RespondNow) or die(mysql_error());
/* $updateGoTo = "";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}*/
header("Location: main.php");
}
?>Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\respondnow\main.php:8) in C:\Program Files\Apache Group\Apache2\htdocs\respondnow\editevent.php on line 55
the thing is when i use framesets to send the clients around I dont get a problem with the header function; as soon as I started using main.php which has the include statements
the php code for main.php is as follows:
Code: Select all
<?php
include ("top.htm");
include ("menu.php");
include ("$type.php");
?>like i said when i use this code i get the header function im convinced its got to do with me using include nad headers simultaneously
thanks again all
feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
this is all the code
this is all the code from top to bottom i've made sure that theres not a single space left anywhere
feyd | Help us, help you. Please use
Code: Select all
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_RespondNow = "localhost";
$database_RespondNow = "respondnow";
$username_RespondNow = "root";
$password_RespondNow = "pass";
$RespondNow = mysql_pconnect($hostname_RespondNow, $username_RespondNow, $password_RespondNow) or trigger_error(mysql_error(),E_USER_ERROR);
?>feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia