emailing variable

A

Anonymous

Guest
Hi. I am having this problem using the email function. I get a cookie and use the value of it to get an array like below: The problem is that when I email the variable, only the last line of the array is sent, not the whole thing. But, everything gets printed on the screen like it should. Can someone help me here? :)
for ($y = 0; $y < 15; $y++) {
$realy=$y+1;
$tempAns= $answers[y];
$tempCorrect= $CorrectAns[y];
//if (strtolower($tempAns)==strtolower($tempCorrect)) {

echo "$speechst Question $realy - Correct.";
//}
//else {
echo "$speechst Question $realy - Incorrect. Actual Answer was :$Explanation[y]";
$ans = "$speechst Question $realy - Incorrect. Actual Answer was :$Explanation[y]";
$body = "$email, $name, $Company, $City, $phone_no, $currentgrade, $currentScore, $ans";
//}
}
//$body = "$email, $name, $Company, $City, $phone_no, $currentgrade, $currentScore, $ans";
$hdr = "From: Infotrends Canada\r\n";
$hdr .= "Return-Path: $someone@somewhere.com\r\n";
if($cc){$hdr .= "Cc: $cc\r\n";}
if($bcc){$hdr .= "Bcc: $bcc\r\n";}
for($i = 0; $i < $sizeof; $i++){
if(mail($to[$i], $subject, $body, $hdr))
{
$status = "Your message was successfully sent.";
}
else
{
$status = "An error occurred while sending your message.";
}
}
 
Since no one replied to my posting as of yet, I am assuming my problem is unsolvable. Thanks anyway.
 
sorry.. I had the weedend off this week. :)

If you are going through an array make sure that you use .= if you wish to combine the information of the array together.

Code:
$sizeof = sizeof($new_array('one','two','three'));

for($x=0; $x<$sizeof; $x++)
{

 $output .= $new_array[$x];
}

echo $output;

this will yield

onetwothree

Code:
$sizeof = sizeof($new_array('one','two','three'));

for($x=0; $x<$sizeof; $x++)
{

 $output = $new_array[$x];
//this is the part to pay attention too

}

echo $output;

this will yield just the last of the array.
 
Hi. Thanks, but I am still having the same problem of not being able to email all of the output that is echoed on the screen. Any reason why?
 
well - firstly you haven't indented your code at all well and there's no highlight syntaxing (just makes it trickier).

next - you haven't mentioned why you're sending multiple emails to (I assume) all the addresses in the $to array

next - where does $subject come from?

and lastly - you've ignored the valid advise (let's call it an answer rather than advice as that's what it was) already given.

why should we help if you don't listen?

I'm not even going to mention the commented lines - you probably think they are helpful for anyone trying to help.
 
Back
Top