close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

The Dreaded Headers Already Sent error

Thread began 1/10/2013 2:45 am by acaciasd344844 | Last modified 1/15/2013 1:41 pm by Jason Byrnes | 1631 views | 5 replies |

acaciasd344844

The Dreaded Headers Already Sent error

Hi Jason,

I am pleased to say that I have the UE working correctly now and producing multiple emails at the touch of a button.

The thing is even though it is working I get quite a lot of header sessions like the following... Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /homepages/37/d277122941/htdocs/midas2demo/pcclient/invoice-email_multi_comm_logo.php:121) in /homepages/37/d277122941/htdocs/midas2demo/pcclient/invoice-email_multi_comm_logo.php on line 202

I read a number of posts especially this one... showthread.php?t=19285

I have spent what feels like hours going through each line of the code to track this down.

But I just cant see or find anything. Could it be something else?

Any clues would be a valuable lesson for the future. I have attached the file causing the error... invoice-email_multi_comm_logo.php

john

Attached Files
john henderson header already sent error.zip
Sign in to reply to this post

Jason ByrnesWebAssist

you have code in the body of the page that should be before the doctype tag.

the code at lines 175 - 288:

php:
<?php

    
// RepeatSelectionCounter_2 Begin Loop
    
$RepeatSelectionCounter_2_IterationsRemaining $RepeatSelectionCounter_2_Iterations;
    while(
$RepeatSelectionCounter_2_IterationsRemaining--){
        if(
$RepeatSelectionCounterBasedLooping_2 || $row_Recordsetmultiprint){            
        
$maxRows_Recordsetdisplayproducts 10;
$pageNum_Recordsetdisplayproducts 0;
if (isset(
$_GET['pageNum_Recordsetdisplayproducts'])) {
  
$pageNum_Recordsetdisplayproducts $_GET['pageNum_Recordsetdisplayproducts'];
}
$startRow_Recordsetdisplayproducts $pageNum_Recordsetdisplayproducts $maxRows_Recordsetdisplayproducts;
$colname_Recordsetdisplayproducts "-1";
if (isset(
$_GET['invoiceid'])) {
  
$colname_Recordsetdisplayproducts $_GET['invoiceid'];
}
$paramInvoiceID_Recordsetdisplayproducts "-1";
if (isset(
$row_Recordsetmultiprint['invoiceid'])) {
  
$paramInvoiceID_Recordsetdisplayproducts = (get_magic_quotes_gpc()) ? $row_Recordsetmultiprint['invoiceid'] : addslashes($row_Recordsetmultiprint['invoiceid']);
}
mysql_select_db($database_midas0001$midas0001);
$query_Recordsetdisplayproducts sprintf("SELECT * FROM products  left join invoice on invoice.invoiceid = products.invoiceid WHERE products.invoiceid = %s AND invoice.print = '1' ORDER BY productid"GetSQLValueString($paramInvoiceID_Recordsetdisplayproducts"int"));
$Recordsetdisplayproducts mysql_query($query_Recordsetdisplayproducts$midas0001) or die(mysql_error());
$row_Recordsetdisplayproducts mysql_fetch_assoc($Recordsetdisplayproducts);
$totalRows_Recordsetdisplayproducts mysql_num_rows($Recordsetdisplayproducts);?>
<?php 
require_once("../webassist/email/mail_php.php"); ?>
<?php 
require_once("../webassist/email/mailformatting_php.php"); ?>
<?php
if (!isset($_SESSION))session_start();
if (((
$_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)))     {
  
//WA Universal Email object="mail"
  
set_time_limit(0);
  
$EmailRef "waue_invoice-email_multi_comm_logo_2";
  
$BurstSize 200;
  
$BurstTime 1;
  
$WaitTime 1;
  
$GoToPage "confirminvoiceprintoption.php";
  
$RecipArray = array();
  
$StartBurst time();
  
$LoopCount 0;
  
$TotalEmails 0;
  
$RecipIndex 0;
  
// build up recipients array
  
$CurIndex sizeof($RecipArray);
  
$RecipArray[$CurIndex] = array();
  
$RecipArray[$CurIndex ][] = "".$row_Recordsetmultiprint['cust_email']  ."";
  
$TotalEmails += sizeof($RecipArray[$CurIndex]);
  
$RealWait = ($WaitTime<0.25)?0.25:($WaitTime+0.1);
  
$TimeTracker = Array();
  
$TotalBursts floor($TotalEmails/$BurstSize);
  
$AfterBursts $TotalEmails $BurstSize;
  
$TimeRemaining = ($TotalBursts $BurstTime) + ($AfterBursts*$RealWait);
  if (
$TimeRemaining < ($TotalEmails*$RealWait) )  {
    
$TimeRemaining $TotalEmails*$RealWait;
  }
  
$_SESSION[$EmailRef."_Total"] = $TotalEmails;
  
$_SESSION[$EmailRef."_Index"] = 0;
  
$_SESSION[$EmailRef."_Remaining"] = $TimeRemaining;
  while (
$RecipIndex sizeof($RecipArray))  {
    
$EnteredValue is_string($RecipArray[$RecipIndex][0]);
    
$CurIndex 0;
    while ((
$EnteredValue && $CurIndex sizeof($RecipArray[$RecipIndex])) || (!$EnteredValue && $RecipArray[$RecipIndex][0])) {
      
$starttime microtime_float();
      if (
$EnteredValue)  {
        
$RecipientEmail $RecipArray[$RecipIndex][$CurIndex];
      }  else  {
        
$RecipientEmail $RecipArray[$RecipIndex][0][$RecipArray[$RecipIndex][2]];
      }
      
$EmailsRemaining = ($TotalEmails$LoopCount);
      
$BurstsRemaining ceil(($EmailsRemaining-$AfterBursts)/$BurstSize);
      
$IntoBurst = ($EmailsRemaining-$AfterBursts) % $BurstSize;
      if (
$AfterBursts<$EmailsRemaining$IntoBurst 0;
      
$TimeRemaining = ($BurstsRemaining $BurstTime 60) + ((($AfterBursts<$EmailsRemaining)?$AfterBursts:$EmailsRemaining)*$RealWait) - (($AfterBursts>$EmailsRemaining)?0:($IntoBurst*$RealWait));
      if (
$TimeRemaining < ($EmailsRemaining*$RealWait) )  {
        
$TimeRemaining $EmailsRemaining*$RealWait;
      }
      
$CurIndex ++;
      
$LoopCount ++;
      
session_commit();
      
session_start();
      
$_SESSION[$EmailRef."_Index"] = $LoopCount;
      
$_SESSION[$EmailRef."_Remaining"] = round($TimeRemaining);
      
session_commit();
      
wa_sleep($WaitTime);
      include(
"../webassist/email/waue_invoice-email_multi_comm_logo_2.php");
      
$endtime microtime_float();
      
$TimeTracker[] =$endtime $starttime;
      
$RealWait array_sum($TimeTracker)/sizeof($TimeTracker);
      if (
$LoopCount $BurstSize == && $CurIndex sizeof($RecipArray[$RecipIndex]))  {
        
$TimePassed = (time() - $StartBurst);
        if (
$TimePassed < ($BurstTime*60))  {
          
$WaitBurst = ($BurstTime*60) -$TimePassed;
          
wa_sleep($WaitBurst);
        }
        else  {
          
$TimeRemaining = ($TotalEmails$LoopCount)*$RealWait;
        }
        
$StartBurst time();
      }
      if (!
$EnteredValue)  {
        
$RecipArray[$RecipIndex][0] =  mysql_fetch_assoc($RecipArray[$RecipIndex][1]);
      }
    }
    
$RecipIndex ++;
  }
  
$_SESSION[$EmailRef."_Total"] = 0;
  
$_SESSION[$EmailRef."_Index"] = 0;
  
$_SESSION[$EmailRef."_Remaining"] = 0;
  
session_commit();
  
session_start();
  if (
$GoToPage!="")     {
    
header("Location: ".$GoToPage);
  }
}
?>



does not belong in the page body. It should come before the doctype tag.

Sign in to reply to this post

acaciasd344844

Blinking Headers

Hi Jason,

I did as you said, but then it stopped producing the emails or sometimes just produced one or two. Apart from the errors the page works exactly as It should now. So feeling a bit frustrated with this blinking page.


john

Sign in to reply to this post

Jason ByrnesWebAssist

what do you mean by blinking headers?

do you have a link where i can see the problem?

Sign in to reply to this post

acaciasd344844

Headers

Hi Jason,

Blinking Headers does not mean they are blinking its just an English term like dammed headers or blasted headers. But they are still repeating themselves although the email is working. As I said I did try moving the code above the doctype but then it would only send one out and then stopped producing the correct data.

John

Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

If anyone else is experiencing this same issue, please append to this thread.

Sign in to reply to this post

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