HeadersAlready Sent
Posted: Tue Feb 01, 2011 1:48 pm
I have been killing myself trying to find out how to get around this issu. I am using SVG GRaph to dynamically plot a graph based on the user and user selection. The graph works on it's own page, however i need to include it within another page which has the page header as an include among others. when I do so it does not work because the header include has already sent the header information.
How can I work around this? I have looked into ob_start()/ ob_flush_end() but am not sure how this works when both the header and the page included both send header information. Any ideas?
Below is the code, Any help with this would be very much appreciated as I have been dealing with this for quite some time now
The main page
Here is the header
How can I work around this? I have looked into ob_start()/ ob_flush_end() but am not sure how this works when both the header and the page included both send header information. Any ideas?
Below is the code, Any help with this would be very much appreciated as I have been dealing with this for quite some time now
The main page
Code: Select all
<?php
include("include/header.inc"); //If I remove this it works, but does not display the header banner and nav menu
include("include/dbc.php");
require('graphs/SVGraph.php');
global $id;
//get desired view from user selection on the body page
$part = $_POST['BodyPart'];
$view = $_POST['view'];
//===============================================================================================
$graph = new LineGraph();
$graph->setGraphTitle('My Body Graph');
$graph->setGraphDescription('Measurement over time');
$graph->setXAxisLabel('Time');
$graph->setYAxisLabel('Measurements');
switch ($view){
case "Month": // -- month VIEW --- =============================================================
$partQuery = mysql_query("SELECT $part FROM indBody WHERE MemberID = '$id' AND DateEntered >= DATE_SUB(CURDATE(), INTERVAL 1 Month) ORDER BY DateEntered");
$count = mysql_query("SELECT COUNT( DISTINCT DateEntered, $part FROM indBody) WHERE MemberID = '$id' AND DateEntered >= DATE_SUB(CURDATE(), INTERVAL '$view' DAY) AND CURDATE() ORDER BY DateEntered");
$plots = array();
$dates = array();
//create part variables
$i = 1;
while($fetchPart = mysql_fetch_array($partQuery)) {
$plot = $fetchPart[$part];
$plots[] = $plot;
$date = $fetchPart['DateEntered'];
$dates[] = sprintf("%02s/%02s", substr($date,0,4),substr($date,5,6));
$i++;
}//end while loop
//Define some data
$graph->setXAxis($dates);
$graph->addDataRow($plots, 'my data row');
//output graph
$graph->output();
break;
default: // -- Any other selection VIEW --- =============================================================
$partQuery = mysql_query("SELECT DISTINCT DateEntered, $part FROM indBody WHERE MemberID = '$id' AND DateEntered >= DATE_SUB(CURDATE(), INTERVAL '$view' DAY) AND CURDATE() ORDER BY DateEntered");
$count = mysql_query("SELECT COUNT(DISTINCT DateEntered, $part FROM indBody) WHERE MemberID = '$id' AND DateEntered >= DATE_SUB(CURDATE(), INTERVAL '$view' DAY) AND CURDATE() ORDER BY DateEntered");
$plots = array();
$dates = array();
//create part variables
$i = 1;
while($fetchPart = mysql_fetch_array($partQuery)) {
$plot = $fetchPart[$part];
$plots[] = $plot;
$date = $fetchPart['DateEntered'];
$dates[] = sprintf("%02s/%02s", substr($date,0,4),substr($date,5,6));
$i++;
}//end while loop
//Define some data
$graph->setXAxis($dates);
$graph->addDataRow($plots, 'my data row');
//output graph
$graph->output();
}//end switch statement
Code: Select all
<?php session_start();?>
<!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" />
<title>Food Fitness First</title>
<link rel="stylesheet" type="text/css" href="./css/master.css" />
<link rel="stylesheet" type="text/css" href="./css/pro_drop.css" />
<link href="calendar/style/style.css" rel="stylesheet" type="text/css" />
<script src="jquery.js" type="text/javascript"></script>
<script src="scripts/stuHover.js" type="text/javascript"></script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-12068429-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
<meta name="google-site-verification" content="o7UaHcuDso80W1_P1K3-Q_IRjY6vmBzN3lQAaiVSnqI" />
</head>
<body>
<!-- Header div -->
<div id="header">
<div id="search">
<div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function(){
var customSearchControl = new google.search.CustomSearchControl('009126769682394590088:l17wlvfwrvq');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setSearchFormRoot('cse-search-form');
customSearchControl.draw('cse', options);
}, true);
</script>
</div>
<a href="http://foodfitnessfirst.com"><img src="./images/header2.png" alt="Food Fitness First, Inc." width="800" border="0" /></a>
<!-- Section area - Individual, Corporate, Professionals - div -->
<center>
<span class="preload1"></span>
<span class="preload2"></span>
<!-- Individual Area options -->
<ul id="nav">
<li class="top"><a href="index.php" class="top_link"><span class="down"> Overview</span></a>
<ul class="sub">
<li><a href="calendar.php">Calendar</a></li>
<li><a href="reports.php">Reports</a></li>
</ul>
</li>
<li class="top"><a href="profile.php" class="top_link"><span class="down"> Myself</span></a>
<ul class="sub">
<li><a href="WeightGoal.php">Weight Goal</a></li>
</ul>
</li>
<li class="top"><a href="foods.php" class="top_link"><span> Food Diary</span></a></li>
<li class="top"><a href="act.php" class="top_link"><span> Exercise Log</span></a></li>
<li class="top"><a href="body.php" class="top_link"><span> Body</span></a></li>
<!--<li class="top"><a href="labs.php" class="top_link"><span class="down">Labs</span></a>
<ul class="sub">
<li><a href="Medications.php">Medications</span></a></li>
</ul>
</li> -->
<li class="top"><a href="weight.php" class="top_link"><span> Weight</span></a></li>
<li class="top"><a href="#" class="top_link"><span class="down">Community</span></a>
<ul class="sub">
<li><a href="http://foodfitnessfirst.com/forum/">Forums</a></li>
<li><a href="contact.php">Send Message to RD</a></li>
<li><a href="read.php">Read Messages</a></li>
</ul>
</li>
<li class="top"><a href="http://foodfitnessfirst.com/subscription/login.php" class="top_link"><span class="down"> Log In </span></a>
<ul class="sub">
<li><a href="http://foodfitnessfirst.com/sub.php">Subscriptions</a></li>
<li><a href="http://foodfitnessfirst.com/subscription/member.php">My Account</a></li>
</ul>
</li>
</ul>
</center>
<br />
<?
$id= $_SESSION['_amember_user']['member_id'];
$fname= $_SESSION['_amember_user']['name_f'];
$lname= $_SESSION['_amember_user']['name_l'];
$user = $fname. " " .$lname;
if($id > 0 ){
echo "Welcome ". $user. ", Not You?, <a href='http://foodfitnessfirst.com/subscription/member.php'> Click here</a>";
}else{
echo 'Not logged in!<a href="http://foodfitnessfirst.com/subscription/member.php"> Log in here</a>';
}
?>
</div>
<div id="wrapper">
<!-- Main content -->
<div id="content" >
<div id="cse" style="width:100%;"></div>