Headers Already Sent

Hi Folks,

I am getting the 'Headers Already Sent ’ error on this bit of code but i can’t figure out why.
Can anyone enlighten me?


<?php require_once('Connections/con_quiz.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;}
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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($mm_abort_edit) || !$mm_abort_edit) {
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frm_answers")) {
  $updateSQL = sprintf("UPDATE score SET `1`=%s, `2`=%s, `3`=%s, `4`=%s, `5`=%s WHERE id=%s",
                       GetSQLValueString($_POST['1'], "int"),
                       GetSQLValueString($_POST['2'], "int"),
                       GetSQLValueString($_POST['3'], "int"),
                       GetSQLValueString($_POST['4'], "int"),
                       GetSQLValueString($_POST['5'], "int"),
                       GetSQLValueString($_POST['id'], "int"));
  mysql_select_db($database_con_quiz, $con_quiz);
  $Result1 = mysql_query($updateSQL, $con_quiz) or die(mysql_error());
  //SET ID to ID +1
  $id2=($id+1);
  $updateGoTo = "question.phpi?d=".$id2."";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];}
  header(sprintf("Location: %s", $updateGoTo));

‘Something’ is being sent to the browser before the redirect can take place.
Can you post the full error message as it tells you exactly where the output has started.

I don’t have it on this machine but it mentions line 39
"//SET ID to ID +1 "

and line 44
$updateGoTo .= $_SERVER[‘QUERY_STRING’];}

I have tried removing line 39 altogether but it made no difference.

Also I noticed the location had an error in it

$updateGoTo = “question.phpi?d=”.$id2.“”;

so I corrected that to
$updateGoTo = “question.php?id=”.$id2.“”;

But that made no difference because it is just not getting that far

Ooops. Yes it did. Must have been cached. Emptied the browser cache and now it’s fixed.