Topic: Dreamweaver CS4 Header Error.

Hello. I've been reading through the site and love the friendly support so thought I would post a problem I've been trying to fix.

Before I begin I'll just say that I do not know that much PHP, I have been using Dreamweaver CS3 and now Dreamweaver CS4 to create my websites. I have created a site very similar to this in the past using CS3 but now in CS4 it has different, updated, code but isn't working properly.

Now, for the problem.

Basically, there are about 6 pages that will all have pretty much the same layout, I have simply duplicated all the pages, put them into another folder i call 'dev' to edit the content on the pages easily. On each of the 'dev' pages I have a border around the editable section (3 per page, an image, and a header and content edited on the same page similar to creating this forum post), and a button at the bottom of that particular piece to go to a new page with the text boxes/buttons etc for editing/updating. So, I'm on the 'home' page, I click on the 'edit' button that will take me to the second page to edit the Header and Content, on that page there is simply two text boxes, one for the header and one for the content, I type in what I want, hit the 'update' button and I get this error:
Warning: Cannot modify header information - headers already sent in /home/xager/public_html/srag/dev/index2.php on line 53
(the 'home' page is updated, but I am meant to go to a 'your updates have been successful' page which will then take me back to the 'home' page, though I am staying on the 'edit' page.)

My code is:

<?php virtual('/Connections/srag_conn.php'); ?>
<?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($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE home SET header=%s, content=%s WHERE id=%s",
                       GetSQLValueString($_POST['header'], "text"),
                       GetSQLValueString($_POST['content'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_srag_conn, $srag_conn);
  $Result1 = mysql_query($updateSQL, $srag_conn) or die(mysql_error());

  $updateGoTo = "success.html";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_srag_conn, $srag_conn);
$query_Recordset1 = "SELECT * FROM home";
$Recordset1 = mysql_query($query_Recordset1, $srag_conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Stanthorpe Regional Art Gallery</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="spar"></div>
<div id="home"><a href="index.php">HOME</a></div>
<div id="exhibitions"><a href="exhibitions.php">EXHIBITIONS</a></div>
<div id="collection"><a href="collection.php">COLLECTION</a></div>
<div id="events"><a href="events.php">EVENTS</a></div>
<div id="public"><a href="public.php">PUBLIC<br />
  PROGRAMS</a></div>
<div id="membership"><a href="membership.php">MEMBERSHIP</a></div>
<div id="contact"><a href="contact.php">CONTACT</a></div>
<div id="homebb"></div>
<div id="content">
  <div id="logo"></div>
  <div id="container">
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
      <table align="center">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Header:</td>
          <td><input type="text" name="header" value="<?php echo ($row_Recordset1['header']); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Content:</td>
          <td><input type="text" name="content" value="<?php echo ($row_Recordset1['content']); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td><input type="submit" value="Update record" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_update" value="form1" />
      <input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
    </form>
    <p>&nbsp;</p>
  </div>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

After searching for what was about 3 hours I found several references to the fact that I might have blank spaces before or after the php opening/closing tags, I checked every single document, found one on a page that had nothing to do with this work. I played with the code, as I don't know much PHP this wasn't too successful, and have been trying to fix this problem for almost a week now.

So, after all that: Can anyone give me some info on why I am getting this error. How to fix it? Possibly using CS4 as I will need to do this quite often and would rather, for the sake of time, not have to type it out, though of course I will if need be.

Thanks for any help and please be patient with me as I am still learning a lot.

Xager.