phpuser1985 Posted October 20, 2009 Share Posted October 20, 2009 im trying to build a delete record behavior but it keeps telling me Warning: Cannot modify header information - headers already sent by (output started at /deleterecord.php:1) in deleterecord.php on line 46. I checked all possible white spacing and have found none. can someone help me out please. thanks. here is the page code: <?php virtual('/Connections/blubeetl.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; } } if ((isset($_GET['recordID'])) && ($_GET['recordID'] != "")) { $deleteSQL = sprintf("DELETE FROM business WHERE id=%s", GetSQLValueString($_GET['recordID'], "int")); mysql_select_db($database_blubeetl, $blubeetl); $Result1 = mysql_query($deleteSQL, $blubeetl) or die(mysql_error()); $deleteGoTo = "admin/baccounts.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/ Share on other sites More sharing options...
Coreye Posted October 20, 2009 Share Posted October 20, 2009 What are the problems and what errors are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940339 Share on other sites More sharing options...
phpuser1985 Posted October 20, 2009 Author Share Posted October 20, 2009 im getting these 2 errors when i go to the specific page to view it: Warning: Cannot modify header information - headers already sent by (output started atdeleteCrecord.php:1) in deleteCrecord.php on line 46 Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940357 Share on other sites More sharing options...
cags Posted October 20, 2009 Share Posted October 20, 2009 They both refer to the same thing, the fact that you cannot modify headers after output to the browser has begun. There is a sticky at the top of this board about the problem. Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940359 Share on other sites More sharing options...
phpuser1985 Posted October 20, 2009 Author Share Posted October 20, 2009 i checked the posting about the headers already sent out and there was no white spaces but im not sure how to write the code so the error doesnt occur. thank you Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940361 Share on other sites More sharing options...
cags Posted October 20, 2009 Share Posted October 20, 2009 Try replacing the header call with a die() call and look at the HTML source and see what character has been output. I'm guessing looking at your code that <?php virtual('/Connections/blubeetl.php');?> is the cause of the problem as their doesn't appear to be a problem anywhere else. Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940385 Share on other sites More sharing options...
PFMaBiSmAd Posted October 20, 2009 Share Posted October 20, 2009 The error states where the output is occuring - output started at /deleterecord.php:1 Unfortunately, you have a php statement on line one of the posted code, so there are two possibilities. You should actually put the opening <?php tag on a line by itself with noting else on the line with it in order to help eliminate the second reason listed below - 1) Your file has been saved in UTF-8 format and the BOM (Byte Order Mark) characters that the editor places at the start of the file IS the content being output on line one. 2) Something in the /Connections/blubeetl.php file is causing output to be sent. This could be before the <?php opening tag, in the body of the file, or even after the ?> closing tag. Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940439 Share on other sites More sharing options...
phpuser1985 Posted October 21, 2009 Author Share Posted October 21, 2009 the thing that stinks is dreamweaver forms all code with the virtual connection at the top of the page. does anyone know way around this?thanks for all your help Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-940877 Share on other sites More sharing options...
phpuser1985 Posted October 21, 2009 Author Share Posted October 21, 2009 hi everyone thanks for all the quick replies i appreciate it. i figured it out i think. dreamweaver just ha a glitch where you need to turn (bom) on save your work then turn it off and save. when i do this the errors dissappear and everything works. weird Quote Link to comment https://forums.phpfreaks.com/topic/178334-solved-dreamweaver-cs4-php-code-errors/#findComment-941125 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.