Page 1 of 1
Warning: Cannot modify header information - headers already
Posted: Wed Sep 10, 2003 2:23 pm
by kendall
Hello, i have the following lines of code in my code
Code: Select all
line: 24 <?php require_once('connection.php'); ?>
<?php
// some code to excute and if sucessful
line 107 header(sprintf("Location: %s", $location));
exit;
this is more or less the flow of ALL my php scripts yet this is the ONLY Page that gives this problems
the exact error is
Warning: Cannot modify header information - headers already sent by (output started at modify_references.php:24) in modify_references.php on line 107
the lines in question are what has been posted and i dont now WTF is the problem
the reason why i say
this is more or less the flow of ALL my php scripts yet this is the ONLY Page that gives this problems
is because the php scripts were built using dreamweaver php builder extensions and this is the pattern for ALL the scripts...ALL only different is the the input information and the database action..
wat...oh wat is driving me CARZY
Kendall
Posted: Wed Sep 10, 2003 2:41 pm
by trollll
In the source, what lines do you have before the line 107? If you have anything printed out it will yell at you just like that. Drove me crazy until I realized that I had output some HTML tags before that line. Once the header gets sent, it won't let you modify it.
Posted: Wed Sep 10, 2003 2:52 pm
by kendall
trolll,
exactly....ah mean i know this so it was the first thing i was looking for...the php process doesn;t need to print anything so i thought it was a mistake i made....but i dont see it... the only thing it probably does is define some new variable
Code: Select all
$editFormAction = $HTTP_SERVER_VARSї'PHP_SELF'];
if (isset($HTTP_SERVER_VARSї'QUERY_STRING']))
$editFormAction .= "?" . $HTTP_SERVER_VARSї'QUERY_STRING'];
if ((isset($HTTP_POST_VARSї"MM_update"])) && ($HTTP_POST_VARSї"MM_update"] == "form1")) {
$errStr = false;
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",30000);
define("DESTINATION_FOLDER", "../images/references_images");
$_accepted_extensions_ = "jpeg,jpg";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
$_file_ = $HTTP_POST_FILESї'IMG'];
if(is_uploaded_file($_file_ї'tmp_name']) && $HTTP_POST_FILESї'IMG']ї'error'] == 0){
$_name_ = $_file_ї'name'];
$_type_ = $_file_ї'type'];
$_tmp_name_ = $_file_ї'tmp_name'];
$_size_ = $_file_ї'size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0)
$errStr = "File Size should NOT exceed 30000Bytes (30KB)";
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_їcount($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0)
$errStr = "Invalid Extension. Please Upload only JPEG('.jpg') extension FILES!!!";
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER))
$errStr = "Could not Upload File. Please check the directory";
if($errStr == false){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_))
$Image = $_name_;
else $errStr = 'Could not Upload File. Please try again';
}
}
if($errStr == false){
$updateSQL = sprintf("UPDATE references_table SET Company=%s, Image=%s, Description=%s, Category=%s WHERE `REF`=%s",
GetSQLValueString($HTTP_POST_VARSї'Company'], "text"),
GetSQLValueString(isset($Image) ? $Image : "NULL", "text"),
GetSQLValueString($HTTP_POST_VARSї'Description'], "text"),
GetSQLValueString($HTTP_POST_VARSї'Category'], "int"),
GetSQLValueString($HTTP_POST_VARSї'REF'], "int"));
mysql_select_db($database_Resco_Products, $Resco_Products);
$Result1 = mysql_query($updateSQL, $Resco_Products) or die(mysql_error());
$Status = 'Reference REF# -'.$HTTP_POST_VARSї'REF'].' updated!';
$updateGoTo = "list_reference.php?Status=".urlencode($Status);
if (isset($HTTP_SERVER_VARSї'QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $HTTP_SERVER_VARSї'QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
exit;
}
now as i said with the above code....im using it as is in a next script give or take a few variable....and it works. can you detect anything here
Kendall
Posted: Wed Sep 10, 2003 4:38 pm
by trollll
Hmmm... Nothing really jumps out at me. You may want to make some variables at different points through the script and initialize them all with headers_set() and the print them all out at the end of the script to narrow it down to a certain section of code. Then you can narrow it down from there to the actual line using the same method.
Posted: Wed Sep 10, 2003 8:24 pm
by m3rajk
you might want to read:
this thread
it was stickied for a reason. if you still need help, then search for "echo" in your code. find the line of the first occurance.
Posted: Thu Sep 11, 2003 3:28 am
by JayBird
can you show us the whole of the code on that page?
Mark
Posted: Thu Sep 11, 2003 8:44 am
by kendall
m3rajk
Master,
AAAAAAAAAAAAAAAHHHHHH....the spaces....the spaces...the spacesss......I had put spaces to separate the code as i was going to comment it however i forgot to put the comments....thanks