Forum Moderators: coopster
This is line 39
header("Location:get_events.php?d=&m=&y=");
Please, if someone could tell me what the deal is, I would be most appreciated. The code below is on the top of the page, NO html is written before it, no in the included file either...
<?ob_start();?>
<?php require 'inc/db_connect.php';?>
<?
# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
# double-up apostrophes
$EventTitle = str_replace("/","'",trim($_POST['_eventTitle']));
$EventDate = $_POST['_eventDate'];
$date_array = explode ("/", $EventDate);
$FormattedEventDate = $date_array[2] ."-" .$date_array[0] ."-" .$date_array[1];
$EventStartTime = $_POST['_eventStartHour'] . ':' . $_POST['_eventStartMinute'] . ' ' . $_POST['_eventStartAMPM'];
$EventEndTime = $_POST['_eventEndHour'] . ':' . $_POST['_eventEndMinute'] . ' ' . $_POST['_eventEndAMPM'];
$Location = str_replace("/","'",trim($_POST['_location']));
$Description = str_replace("/","'",trim($_POST['_description']));
$ContactName = str_replace("/","'",trim($_POST['_contactName']));
$ContactEmail = str_replace("/","'",trim($_POST['_contactEmail']));
$ContactPhone = str_replace("/","'",trim($_POST['_contactPhone']));
# setup SQL statement
$SQL = " INSERT INTO event ";
$SQL = $SQL . " (EventTitle, EventDate, EventStartTime, EventEndTime, Location, Description, ContactName, ContactEmail, ContactPhone) VALUES ";
$SQL = $SQL . " ('$EventTitle', '$FormattedEventDate', '$EventStartTime', '$EventEndTime', '$Location', '$Description', '$ContactName', '$ContactEmail', '$ContactPhone') ";
#execute SQL statement
$result = mysql_db_query($db,"$SQL",$cid);
# check for error
if (!$result)
{
echo("ERROR: " . mysql_error() . "\n$SQL\n");
}
else
{
mysql_close($cid);
ob_flush();
header("Location:get_events.php?d=&m=&y=");
}
#print ($SQL);
}
?>
ob_flush();
header("Location:get_events.php?d=&m=&y=");
The reason you are having this problem is because you are calling ob_flush(), then doing a redirect. ob_flush() sends the buffer to the browser, and once you send data to the browser, you can't use a redirect (or set cookies, or set session variables, for that matter). It's just the way PHP works.
Hope this helps!
ob_flush() [php.net]