close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Cannot modify header information - headers already sent

Thread began 1/22/2010 8:42 am by myron364647 | Last modified 2/03/2010 11:11 am by Jason Byrnes | 8533 views | 15 replies |

myron364647

Cannot modify header information - headers already sent

I'm getting a similar problem as another thread, but no resolves helped any. Here's what I'm getting: (username removed with .x.x.)

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 25

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 34

The code at the top is really basic, just inserting one record from a form on the page to the DB with DataAssist Insert

----------------------------------
<?php require_once("Connections/.x.x.DB.php"); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
// WA Application Builder Insert
if (isset($_POST["Submit"])) // Trigger
{
$WA_connection = $.x.x.DB;
$WA_table = "contact";
$WA_sessionName = "contact_cint";
$WA_redirectURL = "confirm.php";
$WA_keepQueryString = false;
$WA_indexField = "cint";
$WA_fieldNamesStr = "cname|cemail|ccity|cmessage|cpickedup";
$WA_fieldValuesStr = "".((isset($_POST["name"]))?$_POST["name"]:"") ."" . "|" . "".((isset($_POST["emailaddress"]))?$_POST["emailaddress"]:"") ."" . "|" . "".((isset($_POST["city"]))?$_POST["city"]:"") ."" . "|" . "".((isset($_POST["message"]))?$_POST["message"]:"") ."" . "|" . "".((isset($_POST["cpickedup"]))?$_POST["cpickedup"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_DarkMoonDB;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Sign in to reply to this post

Office Guy-172461

See:

Solving the "headers already sent" problem
148/

Sign in to reply to this post

myron364647

As I have already stated, previous solutions, including this one, is not the problem. There are no spaces...checked and double checked.

Sign in to reply to this post

Jason ByrnesWebAssist

the error is saying that the output is at line 1:
output started at /home/.x.x./public_html/contact.php:1

This problem can happen if you select the option in Dreamweaver to Include Unicode Signature (BOM) On creating New pages or when saving, it is a PHP bug:
bug.php?id=22108

to fix the problem, Go to File -> Save As. In the Save As Dialogue box, uncheck the Include Unicode Signature (BOM) option.

you should make sure that this option is not set in Dreamweavers preferences as well.

Go to Edit -> Preferences, in the new Document section, uncheck the Include Unicode Signature (BOM) option.

Sign in to reply to this post

Office Guy-172461

This is also discussed in the link I provided.

Sign in to reply to this post

Jason ByrnesWebAssist

Office Guy,

yeah, I saw it there on your page, it is a little bit unclear though. it states that is is a PHP bug, but does not mention the conditions it applies to. To pinpoint it as the cause of the problem, look at the error message:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 25

the important part, is the portion that mentions where the output started:
output started at /home/.x.x./public_html/contact.php:1


You identify the cause as being the BOM Bug by the output starting at line 1.

Sign in to reply to this post

Office Guy-172461

Originally Said By: Jason Byrnes
  You identify the cause as being the BOM Bug by the output starting at line 1.  



Article has been updated to include this tip.

Sign in to reply to this post

myron364647

After moving some code around, getting this error. the :1 still exists, and other line numbers have changed some:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 21

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at /home/.x.x./public_html/contact.php:1) in /home/.x.x./public_html/contact.php on line 30
---------------------------------------------

<?php require_once("Connections/.x.x.DB.php"); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
// WA Application Builder Insert
if (isset($_POST["Submit"])) // Trigger
{
$WA_connection = $.x.x.DB;
$WA_table = "contact";
$WA_sessionName = "contact_cint";
$WA_redirectURL = "confirm.php";
$WA_keepQueryString = false;
$WA_indexField = "cint";
$WA_fieldNamesStr = "cname|cemail|ccity|cmessage|cpickedup";
$WA_fieldValuesStr = "".((isset($_POST["name"]))?$_POST["name"]:"") ."" . "|" . "".((isset($_POST["emailaddress"]))?$_POST["emailaddress"]:"") ."" . "|" . "".((isset($_POST["city"]))?$_POST["city"]:"") ."" . "|" . "".((isset($_POST["message"]))?$_POST["message"]:"") ."" . "|" . "".((isset($_POST["cpickedup"]))?$_POST["cpickedup"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_.x.x.DB;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!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"><!-- InstanceBegin template="/Templates/dm-template-public.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>

Should I just recreate the page again from scratch?

Sign in to reply to this post

Jason ByrnesWebAssist

can you send a copy of one of the pages you are having this issue with so I can examine the page.

It is possible that the BOM Attribute is being added by the server once the page is uploaded.

Sign in to reply to this post

myron364647

You'll find contact.zip attached

Attached Files
contact.zip
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...