Jump to content

Yet another header problem... Help...


00falcon

Recommended Posts

Hi Guys...

 

After searching for hours.... and realizing that this is a common problem and usually quiet easily solved... i feel so bad for not being able to solve it... and having to ask...

 

So... can some one have a look at my code... and see where im going wrong...

 

I have checked for "White Space" and removed what i found...

I have included my 'includes" in the file as opposed to including them.

i have removed my session based login system.

but still i can not see where im going wrong...

 

I am quite new to php (Duh) i have written a simple insert and update scripts to achive what i want to do...

 

but i now have a plug in that "plugs in" to dreamweavers insert and update function... so i would like to get this right...

The code is all produced by Dreamweaver...

 

I have built a test page totaly seperate from this.... using a differant DB Table... and i can get it to work as it shoud...

 

I have removed all my code from this HTML page... and rebuilt it... but i get the same error...

 

Sorry peoples for posting nearly 300 line of code....

 

But i am (stuck)

 

the error is

Warning: Cannot modify header information - headers already sent in /www/virtual/***/htdocs/assets/admin/containers/edit.php on line 66

 

sorry... and my 300 line of code is

<?php virtual('/Connections/OrconDB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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"] == "updateContainer")) {
  $updateSQL = sprintf("UPDATE Con_Containers SET Con_RCN_Ref=%s, Con_Origin=%s, Contact=%s, Contact_Phone=%s, Contact_Email=%s, Con_Number=%s, Con_Seal=%s, `size`=%s, Con_Destination=%s, Carrier=%s, Con_Contents=%s, Con_Contents_Description=%s, Con_Value=%s, Con_Land_Date=%s, Con_Lift_Date=%s, Con_Arival_Date=%s, Con_Invoiced=%s WHERE id=%s",
                       GetSQLValueString($_POST['Con_RCN_Ref'], "text"),
                       GetSQLValueString($_POST['Con_Origin'], "text"),
                       GetSQLValueString($_POST['contact'], "text"),
                       GetSQLValueString($_POST['Contact_Phone'], "text"),
                       GetSQLValueString($_POST['Contact_Email'], "text"),
                       GetSQLValueString($_POST['Con_Number'], "text"),
                       GetSQLValueString($_POST['Con_Seal'], "text"),
                       GetSQLValueString($_POST['size'], "text"),
                       GetSQLValueString($_POST['Con_Destination'], "text"),
                       GetSQLValueString($_POST['carrier'], "text"),
                       GetSQLValueString($_POST['Con_Contents'], "text"),
                       GetSQLValueString($_POST['Con_Contents_Description'], "text"),
                       GetSQLValueString($_POST['Con_Value'], "text"),
                       GetSQLValueString($_POST['Con_Land_Date'], "text"),
                       GetSQLValueString($_POST['Con_Lift_Date'], "text"),
                       GetSQLValueString($_POST['Con_Arival_Date'], "text"),
                       GetSQLValueString($_POST['Con_Invoiced'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_OrconDB, $OrconDB);
  $Result1 = mysql_query($updateSQL, $OrconDB) or die(mysql_error());

  $updateGoTo = "update_ok.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_containers = "-1";
if (isset($_GET['id'])) {
  $colname_containers = $_GET['id'];
}
mysql_select_db($database_OrconDB, $OrconDB);
$query_containers = sprintf("SELECT * FROM Con_Containers WHERE id = %s", GetSQLValueString($colname_containers, "int"));
$containers = mysql_query($query_containers, $OrconDB) or die(mysql_error());
$row_containers = mysql_fetch_assoc($containers);
$totalRows_containers = mysql_num_rows($containers);

mysql_select_db($database_OrconDB, $OrconDB);
$query_destinations = "SELECT * FROM Con_Destinations";
$destinations = mysql_query($query_destinations, $OrconDB) or die(mysql_error());
$row_destinations = mysql_fetch_assoc($destinations);
$totalRows_destinations = mysql_num_rows($destinations);

mysql_select_db($database_OrconDB, $OrconDB);
$query_carrier = "SELECT * FROM con_Carriers";
$carrier = mysql_query($query_carrier, $OrconDB) or die(mysql_error());
$row_carrier = mysql_fetch_assoc($carrier);
$totalRows_carrier = mysql_num_rows($carrier);

mysql_select_db($database_OrconDB, $OrconDB);
$query_size = "SELECT * FROM Con_Size";
$size = mysql_query($query_size, $OrconDB) or die(mysql_error());
$row_size = mysql_fetch_assoc($size);
$totalRows_size = mysql_num_rows($size);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Your description goes here..." />
<link rel="stylesheet" type="text/css" href="../../css/style.css" title="1024px style" media="screen,projection" />
<title>RCN & Associates Ltd - E waste and Remarketing Leaders</title>
</head>
<body>
<div id="wrap">
  <div id="header">
    <p id="toplinks">
      Skip to: <a href="/index.php">Home</a> | <a href="/ewaste_pricing.php">E waste Prices</a>  | <a href="/secure/index.php">Price List</a> | <a href="/flyer"> Sales Flyer</a> | <a href="/contactus.php">Contact us</a></p>
  </div>
  <div id="content">
    <h1>Container Details...</h1>
    <div align="center">
      <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="updateContainer" id="updateContainer">
<input name="id" type="hidden" id="id" />

        <table width="670" border="0" class="border greyBackground">
          <tr>
            <td><strong> Refferance :              </strong></td>
            <td><input name="Con_RCN_Ref" type="text" id="Con_RCN_Ref" value="<?php echo $row_containers['Con_RCN_Ref']; ?>" /></td>
            <td><strong> Origin :            </strong></td>
            <td><input name="Con_Origin" type="text" id="Con_Origin" value="<?php echo $row_containers['Con_Origin']; ?>" /></td>
          </tr>
          <tr>
            <td><strong>Container Number : </strong></td>
            <td><input name="Con_Number" type="text" id="Con_Number" value="<?php echo $row_containers['Con_Number']; ?>"></td>
            <td><strong> Destination : </strong></td>
            <td><select name="Con_Destination" id="Con_Destination">
              <?php
do {  
?>
              <option value="<?php echo $row_destinations['Destination']?>"<?php if (!(strcmp($row_destinations['Destination'], $row_containers['Con_Destination']))) {echo "selected=\"selected\"";} ?>><?php echo $row_destinations['Destination']?></option>
              <?php
} while ($row_destinations = mysql_fetch_assoc($destinations));
  $rows = mysql_num_rows($destinations);
  if($rows > 0) {
      mysql_data_seek($destinations, 0);
  $row_destinations = mysql_fetch_assoc($destinations);
  }
?>
            </select></td>
          </tr>
          <tr>
            <td width="144"><strong>Seal Number :</strong></td>
            <td width="144"><input name="Con_Seal" type="text" id="Con_Seal" value="<?php echo $row_containers['Con_Seal']; ?>"></td>
            <td><strong>Carrier :</strong></td>
            <td width="195"><select name="carrier" id="carrier">
              <?php
do {  
?>
              <option value="<?php echo $row_carrier['carrier']?>"<?php if (!(strcmp($row_carrier['carrier'], $row_containers['Carrier']))) {echo "selected=\"selected\"";} ?>><?php echo $row_carrier['carrier']?></option>
              <?php
} while ($row_carrier = mysql_fetch_assoc($carrier));
  $rows = mysql_num_rows($carrier);
  if($rows > 0) {
      mysql_data_seek($carrier, 0);
  $row_carrier = mysql_fetch_assoc($carrier);
  }
?>
            </select></td>
          </tr>
          <tr>
            <td width="144"><strong>Contents :</strong></td>
            <td width="144"><input name="Con_Contents" type="text" id="Con_Contents" value="<?php echo $row_containers['Con_Contents']; ?>"></td>
            <td><strong>Size :</strong></td>
            <td width="195"><select name="size" id="size">
              <?php
do {  
?>
              <option value="<?php echo $row_size['size']?>"<?php if (!(strcmp($row_size['size'], $row_containers['size']))) {echo "selected=\"selected\"";} ?>><?php echo $row_size['size']?></option>
              <?php
} while ($row_size = mysql_fetch_assoc($size));
  $rows = mysql_num_rows($size);
  if($rows > 0) {
      mysql_data_seek($size, 0);
  $row_size = mysql_fetch_assoc($size);
  }
?>
            </select></td>
          </tr>

          <tr>
            <td><strong>Contents Description:</strong></td>
            <td colspan="3"><textarea name="Con_Contents_Description" id="Con_Contents_Description" cols="55" rows="5"><?php echo $row_containers['Con_Contents_Description']; ?></textarea></td>
          </tr>
          <tr>
            <td><strong>Perceived Value :</strong></td>
            <td><input name="Con_Value" type="text" id="Con_Value" value="<?php echo $row_containers['Con_Value']; ?>"></td>
            <td> </td>
            <td> </td>
          </tr>
          <tr>
            <td><strong>Land :</strong></td>
            <td><strong>Lift :</strong></td>
            <td><strong>Arrive at Destination :</strong></td>
            <td> </td>
          </tr>
          <tr>
            <td><input name="Con_Land_Date" type="text" id="Con_Land_Date" value="<?php echo $row_containers['Con_Land_Date']; ?>"></td>
            <td><input name="Con_Lift_Date" type="text" id="Con_Lift_Date" value="<?php echo $row_containers['Con_Lift_Date']; ?>"></td>
            <td><input name="Con_Arival_Date" type="text" id="Con_Arival_Date" value="<?php echo $row_containers['Con_Arival_Date']; ?>" /></td>
            <td> </td>
          </tr>
          <tr>
            <td><strong>Contact:</strong></td>
            <td><input name="contact" type="text" id="contact" value="<?php echo $row_containers['Contact']; ?>" /></td>
            <td><strong>Contact Phone:</strong></td>
            <td><input name="Contact_Phone" type="text" id="Contact_Phone" value="<?php echo $row_containers['Contact_Phone']; ?>" /></td>
          </tr>
          <tr>
            <td><strong>Contact Email:</strong></td>
            <td colspan="2"><input name="Contact_Email" type="text" id="Contact_Email" value="<?php echo $row_containers['Contact_Email']; ?>" size="45" /></td>
            <td></td>
          </tr>
          <tr>
            <td colspan="2"><input type="file" name="fileField" id="fileField" /></td>
            <td><strong>Invoiced </strong>Yes
              <input <?php if (!(strcmp($row_containers['Con_Invoiced'],"Yes"))) {echo "checked=\"checked\"";} ?>     type="radio" name="Con_Invoiced" id="Con_Invoiced3" value="Yes" />
/ No
<input <?php if (!(strcmp($row_containers['Con_Invoiced'],"No"))) {echo "checked=\"checked\"";} ?>     type="radio" name="Con_Invoiced" id="Con_Invoiced4" value="No" /></td>
            <td><input type="submit" name="button" id="button" value="Update Entry" />
              </td>
          </tr>
        </table>
        <input type="hidden" name="MM_update" value="updateContainer" />
      </form>
    </div>
  </div>
  <div id="sidebar">
<h2><font color="#FF0000">Administration ! </font></h2>
   <ul>
<li><a href="/index.php">***</a></li>
<li><a href="http://webmail.***" target="_blank">RCN Webmail</a> </li>
      <li><a href="http://dbadmin.***/phpmyadmin/" target="_blank">DB Admin</a></li>
      <li><a href="logoutAction.php">Log Out</a></li>
</ul>
    <h2>Functions:</h2>
    <ul>
      <li><a href="/assets/admin/index.php">Admin Home </a></li>
      <li><a href="/assets/admin/containers/index.php">Containers</a></li>
      <li><a href="/assets/admin/containers/list.php">Container List</a> </li>
      <li><a href="/collections">Collections</a></li>
      <li><a href="/assets/admin/rma">RMA Requests </a> </li>
      <li><a href="blog/wp-admin/" target="_blank">Media Admin</a> </li>
      <li><a href="http://www.***.co.nz/admin/index.php" target="_blank">Battery Admin </a> </li>
      <li><a href="/assets/admin/flyeradmin">Flyer Admin </a></li>
    </ul>
    <h2>Pricelist:</h2>
<ul>
      <li><a href="/assets/admin/desktops.php">Desktop Pricing </a></li>
      <li><a href="/assets/admin/laptops.php">Laptop Pricing </a> </li>
      <li><a href="/assets/admin/monitors.php">Monitor Pricing </a></li>
      <li><a href="/assets/admin/printers.php">Printer Pricing </a></li>
      <li><a href="/assets/admin/servers.php">Server Pricing </a></li>
      <li><a href="/assets/admin/users.php">Price List Users</a></li>
      <li><a href="/assets/admin/editUsers.php">Edit Price List Users</a> </li>
</ul>
    <h2>Homeless:</h2>
    <ul>
      <li><a href="datacom_receipt_form.php">Datacom NZP Receipt Form >> </a></li>
      <li><a href="../../datacom/index.php">Datacom View Collections</a></li>
      <li><a href="../../dell">Dell Collections </a></li>
    </ul>    </div>
  <div id="footer">
    <p> </p>
    <p><a href="#">Contact us</a> | <a href="../../terms.php">Terms & Conditions </a> | <a href="../../sitemap.php">Sitemap</a> | <a href="#header">Back to top</a><br />
      © 2008***F| Freelance design by <a href="http://www.****.net.nz">***</a> </p>
  </div>
</div>
</body>
</html>
<?php
mysql_free_result($containers);
mysql_free_result($destinations);
mysql_free_result($carrier);
mysql_free_result($size);
?>

 

Link to comment
https://forums.phpfreaks.com/topic/134953-yet-another-header-problem-help/
Share on other sites

The error is simply fixed. header cannot be called prior to ANY output being sent to the browser.

 

Check all files involved to see if there is any whitespace outside of <?php ?> tags.

 

You code (or dreamweavers) also has html scattered throughout. Is this being displayed before the call to header? It can't be.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.