SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Code:
    <?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));

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    '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.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops. Yes it did. Must have been cached. Emptied the browser cache and now it's fixed.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •