Jump to content

Warning: Cannot modify header information - headers already sent by


andrew_ww

Recommended Posts


I'll try again:

[code]<?php
// Get MySQL connection
require_once('../required/conn.php');
// Begin session
if (!isset($_SESSION)) {
  session_start();
}
// If user session is not set redirect to login page
if(!isset($_SESSION['authenticated'])) {
          header("location: ../?notification=pleaselogin");
}
// Logout link
$logout = $_SERVER['PHP_SELF']."?begone=true";
// If user chooses to logout unset session and redirect
if(isset($_REQUEST['begone']) && $_REQUEST['begone'] == true) {
    $_SESSION['authenticated'] = NULL;
    unset($_SESSION['authenticated']);
    header("location: ../index.php?notification=loggedout");
}
// Get user's ID from session
$userID = $_SESSION['authenticated'];
?>
<?php require_once('../Connections/db.php'); ?>
<?php
$IP_LOG = $_SERVER["REMOTE_ADDR"];
$HOSTNAME_LOG = gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>



<?php
$colname_rs_table1 = "1";
if (isset($_GET['recordID'])) {
  $colname_rs_table1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_db, $db);
//$query_rs_table1 = sprintf("SELECT * FROM tbl_table1 INNER JOIN table2 ON (tbl_table1.id = table2.id) WHERE table2.id = %s", $colname_rs_table1);
$query_rs_table1 = sprintf("SELECT * FROM table2 WHERE table2.id = %s", $colname_rs_table1);
$rs_table1 = mysql_query($query_rs_table1, $DII) or die(mysql_error());
$row_rs_table1 = mysql_fetch_assoc($rs_table1);
$totalRows_rs_table1 = mysql_num_rows($rs_table1);
?>

<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE table2 SET sub=%s WHERE id=%s",
                      GetSQLValueString($_POST['sub'], "text"),
                      GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_db, $db);
  $Result1 = mysql_query($updateSQL, $db) or die(mysql_error());

  $updateGoTo = "index.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
?> [/code]
Link to comment
Share on other sites

which line is the header being sent by....

The only reason to get this error is that your code is outputting to the browser before you are trying to do the header call. Make sure you are not echoing anything, or no other html is being outputted. OR wrap the whole thing in ob_start() at the beginning, and ob_end_flush() at the bottom.

also did you read this

http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

It is on the main page of php help titled HEADER ERRORS - READ HERE BEFORE POSTING THEM

Link to comment
Share on other sites

Yes, ob_start and ob_end_flush are acceptable, however I agree with genericnumber1 , since all the code is php just have a <?php to start and ?> to end  you are starting and ending php several times

[code]$HOSTNAME_LOG = gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>
//whitespace
//whitespace
//whitespace
<?php
$colname_rs_table1 = "1";[/code]
[code]
?>
//whitespace
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{[/code]

remove those whitespace lines and your code should be golden

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.