00falcon Posted November 21, 2008 Share Posted November 21, 2008 Hi Peoples... Somewhat new at PHP & MySQL... i have hand written some simple scripts to display insert and update my info in MySQL... and they all work (not neat... but they work...)... But it took me far too long... so i thought id try and use dreamweaver to do these simple functions... seamed to all go to plan.. Can insert... But cant update... Well.... it does update... but it doesnt forward me on to the correct page... I get the error Warning: Cannot modify header information - headers already sent in /www/virtual/****/htdocs/assets/admin/con_edit.php on line 64 No dreamweaver extensions used... so this is all from Dreamweaver CS3 I have been thru my file(s) and removed all the leading and trailing "white space" as google pointed me in this direction... can someone have a look at the code output by dreamweaver and see where im going wrong... Thanks <?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, Con_Number=%s, Con_Seal=%s, Con_Destination=%s, Con_Contents=%s, Con_Contents_Description=%s, Con_Value=%s, Con_Profit=%s, Con_Land_Date=%s, Con_Lift_Date=%s, Con_Departure_Date=%s, Con_Arival_Date=%s, Con_Finalisation_Date=%s, Con_Invoiced=%s WHERE id=%s", GetSQLValueString($_POST['Con_RCN_Ref'], "text"), GetSQLValueString($_POST['Con_Origin'], "text"), GetSQLValueString($_POST['Con_Number'], "text"), GetSQLValueString($_POST['Con_Seal'], "text"), GetSQLValueString($_POST['Con_Destination'], "text"), GetSQLValueString($_POST['Con_Contents'], "text"), GetSQLValueString($_POST['Con_Contents_Description'], "text"), GetSQLValueString($_POST['Con_Value'], "text"), GetSQLValueString($_POST['Con_Profit'], "text"), GetSQLValueString($_POST['Con_Land_Date'], "text"), GetSQLValueString($_POST['Con_Lift_Date'], "text"), GetSQLValueString($_POST['Con_Departure_Date'], "text"), GetSQLValueString($_POST['Con_Arival_Date'], "text"), GetSQLValueString($_POST['Con_Finalisation_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 = "/assets/admin/containers.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); ?><!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..." /> <meta name="keywords" content="your,keywords,goes,here" /> <meta name="author" content="Your Name" /> <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"> <?php include('../../toplinks.php') ?> </p> </div> <div id="content"> <h1>Container Details...</h1> <div align="center"> <form action="<?php echo $editFormAction; ?>" method="POST" name="updateContainer" id="updateContainer"> <input name="id" type="hidden" id="id" value="<?php echo $row_containers['id']; ?>" /> <table width="670" border="0" class="border greyBackground"> <tr> <td colspan="2">RCN Refferance : <input name="Con_RCN_Ref" type="text" id="Con_RCN_Ref" value="<?php echo $row_containers['Con_RCN_Ref']; ?>"></td> <td colspan="2">Container Origin : <input name="Con_Origin" type="text" id="Con_Origin" value="<?php echo $row_containers['Con_Origin']; ?>"></td> </tr> <tr> <td>Container Number : </td> <td><input name="Con_Number" type="text" id="Con_Number" value="<?php echo $row_containers['Con_Number']; ?>"></td> <td>Container Destination : </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="136">Seal Number :</td> <td width="168"><input name="Con_Seal" type="text" id="Con_Seal" value="<?php echo $row_containers['Con_Seal']; ?>"></td> <td width="139">Container Contents :</td> <td width="209"><input name="Con_Contents" type="text" id="Con_Contents" value="<?php echo $row_containers['Con_Contents']; ?>"></td> </tr> <tr> <td>Contents Description:</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>Value :</td> <td><input name="Con_Value" type="text" id="Con_Value" value="<?php echo $row_containers['Con_Value']; ?>"></td> <td>Profit :</td> <td><input name="Con_Profit" type="text" id="Con_Profit" value="<?php echo $row_containers['Con_Profit']; ?>"></td> </tr> <tr> <td>Land at RCN :</td> <td>Lift from RCN :</td> <td>Depart Auckland :</td> <td>Arrive at Destination :</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_Departure_Date" type="text" id="Con_Departure_Date" value="<?php echo $row_containers['Con_Departure_Date']; ?>"></td> <td><input name="Con_Arival_Date" type="text" id="Con_Arival_Date" value="<?php echo $row_containers['Con_Arival_Date']; ?>"></td> </tr> <tr> <td colspan="2">Expected Finalisation Date:</td> <td colspan="2">Invoiced : Yes <input <?php if (!(strcmp($row_containers['Con_Invoiced'],"Yes"))) {echo "checked=\"checked\"";} ?> type="radio" name="Con_Invoiced" id="Con_Invoiced2" value="Yes" /> / No <input <?php if (!(strcmp($row_containers['Con_Invoiced'],"No"))) {echo "checked=\"checked\"";} ?> type="radio" name="Con_Invoiced" id="Con_Invoiced" value="No" /></td> </tr> <tr> <td colspan="2"><input name="Con_Finalisation_Date" type="text" id="Con_Finalisation_Date" value="<?php echo $row_containers['Con_Finalisation_Date']; ?>" /></td> <td>ID:</td> <td><input type="submit" name="button" id="button" value="Update Entry" /> <a><img src="/assets/admin/delEntry.gif" alt="" width="70" height="20" /></a></td> </tr> </table> <input type="hidden" name="MM_update" value="updateContainer" /> </form> </div> </div> <div id="sidebar"> <?php include('adminMenu.php'); ?> </div> <div id="footer"> <p> </p> </div> </div> </body> </html> <?php mysql_free_result($containers); mysql_free_result($destinations); ?> Quote Link to comment https://forums.phpfreaks.com/topic/133673-cannot-modify-header-writen-using-dreamweaver/ Share on other sites More sharing options...
xangelo Posted November 21, 2008 Share Posted November 21, 2008 Basically what happen is exactly as the error message described. Generally you need to put the header value at the very top of the script, but since you have some processing, we can get around this constraint if you do the following: 1. At the top if your script add this: ob_start(); Make sure that it is on the top most line in your page, it should come right after the opening php tag. All other code should be below it. 2.At the very end, after all your code add this: ob_flush(); It's called output buffering Quote Link to comment https://forums.phpfreaks.com/topic/133673-cannot-modify-header-writen-using-dreamweaver/#findComment-695553 Share on other sites More sharing options...
Maq Posted November 21, 2008 Share Posted November 21, 2008 Please read this first... Quote Link to comment https://forums.phpfreaks.com/topic/133673-cannot-modify-header-writen-using-dreamweaver/#findComment-695554 Share on other sites More sharing options...
00falcon Posted December 6, 2008 Author Share Posted December 6, 2008 Hi All... i dont really know what i did... but i got my page working... Inside dreamweaver's site manager i set it to: Links relative to: Document as opposed to Site root... dont know why... but now all my update scripts work... Quote Link to comment https://forums.phpfreaks.com/topic/133673-cannot-modify-header-writen-using-dreamweaver/#findComment-707335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.