Hi everyone - Evo 1.0.12
I have been getting the familiar old "
Cannot modify header information - headers already sent" error message and it is driving me crazy.
No white space before or after, Utf-8 with NO BOM - tried pretty much everything I could find online - PLEASE HELP.
*******
The full error message is - Warning: Cannot modify header information - headers already sent by (output started at /home/rsacours/public_html/assets/modules/coursemanager/process.cm.php:11) in /home/rsacours/public_html/manager/includes/document.parser.class.inc.php on line 3595
Error
(Note: The line number referenced here - process.cm.php:11 is the one following this line
below)
*******
I have a (Course Manager) module that manages some custom tables. One of the functions is to update/edit course numbers which works fine for the first row (red box in attached image) but for all subsequent rows the above error is generated.
Two files are involved here - 1.
process.cm.php which is called to process the POSTED data and 2.
index.cm.php which is the GUI for the Course Manager Module.
If anyone can spot the issue in the offending file below I would be eternally grateful.
1. process.cm.php
<html>
<head>
</head>
<body>
<div id="padbox">
<?php
// include the modx config and parser -- Modified by WSG - 10/01/2014 added places
require_once('../../../manager/includes/config.inc.php');
require_once('../../../manager/includes/document.parser.class.inc.php');
$modx = new DocumentParser;
// ******** NEW SESSION **********
if($_POST['add_new']==1){
$c=$_POST['course'];
$d=$_POST['date'];
$t=$_POST['time'];
$v=$_POST['venue'];
$p=$_POST['places'];
// ****** ADD NEW SESSION ********** WSG
$sql = "INSERT INTO xtra_session VALUES(NULL,$c,$v,'$d','$t',$p)";
$add = $modx->db->query($sql);
$msg = ($add? "new session has been added" : "error: ".mysql_error());
}
// ******** REMOVE SESSION **********
if($_POST['remove']==1){
$id=$_POST['sid'];
$sql = "DELETE FROM xtra_session WHERE xtra_session.id=$id";
$add = $modx->db->query($sql);
$msg = ($add? "session has been deleted" : "error: ".mysql_error());
}
// ******** EDIT SESSION PLACES ********** WSG
if($_POST['edit']==1){
$id=$_POST['sid'];
$z=$_POST['edit_places'];
$sql = "UPDATE xtra_session SET places=$z WHERE xtra_session.id=$id";
$add = $modx->db->query($sql);
$msg = ($add? "The available places have been updated" : "error: ".mysql_error());
}
else {
echo "Please enter a number of places to change";
}
}
echo $msg;
?>
<form><input type="button" value="Back to admin page" onclick="history.go(-1); return true;" /></form>
<noscript style="color:#c00">oh dear... looks like you have no javascript and the button is broken, click Course Manager from top menu to continue</noscript>
</div>
</body>
</html>
and 2. index.cm.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="media/style/<?php echo $modx->config['manager_theme']; ?>/style.css" />
<link rel="stylesheet" type="text/css" href="../assets/modules/coursemanager/cm_style.css" />
<script type="text/javascript" src="../assets/modules/coursemanager/calendarDateInput.js"></script>
<script type="text/javascript" src="../assets/modules/coursemanager/input.js"></script>
</head>
<body>
<noscript style="color:#c00">oh dear... it looks like you have no javascript, continue at your own risk! This module recommends you turn your javascript on.</noscript>
<div id="padbox">
<h1>Course Manager</h1>
<!-- add session -->
<!-- this block of code has been removed for brevity -->
<!-- ******************************************************************************* -->
<!-- list all sessions with edit places and removal option WSG 11/01/2014-->
<h2 class="section">Currently available sessions</h2>
<table cellspacing="0" cellpadding="5">
<tr><th>ID</th><th>Course</th><th>yyyy-mm-dd</th><th>Venue</th><th>Time</th><th>Places</th><th>New #</th><th> </th></tr>
<?php
$q2="SELECT xtra_session.id AS id,xtra_courses.code AS code,xtra_session.date AS date,xtra_session.time AS time, xtra_session.places AS places, xtra_venues.name AS venue FROM xtra_session,xtra_courses,xtra_venues WHERE xtra_session.date >= CURDATE() AND xtra_session.course_id=xtra_courses.id AND xtra_session.venue_id=xtra_venues.id ORDER BY xtra_session.course_id, xtra_session.date";
$r2= mysql_query($q2);
while($details = mysql_fetch_array($r2)){
$sid = $details['id'];
$code = $details['code'];
$date = $details['date'];
$venue = $details['venue'];
$time = $details['time'];
$places = $details['places'];
echo '<tr'.(($c = !$c)?' class="o"':' class="e"').">";
echo"<td>".$sid."</td>";
echo"<td>".$code."</td>";
echo"<td>".$date."</td>";
echo"<td>".$venue."</td>";
echo"<td>".$time."</td>";
echo"<td>".$places."</td>";
<!-- The block below is the code that works for the first row only then produces the ERROR -->
echo"<td><form name=\"edit_session\" id=\"edit_session\" method=\"post\" action=\"../assets/modules/coursemanager/process.cm.php\"><input type=\"hidden\" name=\"edit\" value=\"1\" /><input type=\"text\" size=\"3\" name=\"edit_places\" value=\" \" /><input type=\"hidden\" name=\"sid\" value=\"".$sid."\" /><input type=\"button\" name=\"Submit\" value=\"edit places\" onclick=\"return resetForm();\"/></form></td>";
echo"<td><form name=\"remove_session".$sid."\" method=\"post\" action=\"../assets/modules/coursemanager/process.cm.php\" onsubmit=\"return check_del();\"><input type=\"hidden\" name=\"remove\" value=\"1\" /><input type=\"hidden\" name=\"sid\" value=\"".$sid."\" /><input type=\"submit\" name=\"Submit\" value=\"delete session\" /></form></td>\n\n";
echo"</tr>";
}
?>
</table>
<p> </p>
<!-- list all sessions with removal option -->
<!-- this block of code has been removed for brevity -->
<!-- ******************************************************************************* -->
<!-- list all courses -->
<!-- this block of code has been removed for brevity -->
<!-- ******************************************************************************* -->
<!-- list all venues -->
<!-- this block of code has been removed for brevity -->
<!-- ******************************************************************************* -->
</div>
<script language="javascript">
function resetForm()
{
document.forms["edit_session"].submit(); //first submit the form values
document.forms["edit_session"].reset(); //then reset the form values
}
</script>
</body>
</html>
[ed. note: Twobears last edited this post 10 years, 3 months ago.]