Jump to content

Archived

This topic is now archived and is closed to further replies.

kc27

Want to Change Output to CSV

Recommended Posts

Hello All

I want to change my script so that it outputs a comma separated text. Immediately below is what I started with, and below that is what I changed it to in order to get it to put CSV text in the email body.

I get an error stating that: Parse error: parse error, unexpected '\"' in in retention.php on line 81

Any ideas on what change I need to do to fix this?

Thanks in advance for your help



THIS IS A PORTION OF THE ORIGINAL SCRIPT
//Sending Email to form owner
$pfw_header = "From: me@myemail.com\n"
  . "Reply-To: me@myemail.com\n";
$pfw_subject = "Retention Summary";
$pfw_email_to = "you@youremail.com";
$pfw_message = "Visitor's IP: $pfw_ip\n"
. "sflteam: $sflteam\n"
. "teamemail: $teamemail\n"
. "Last_Name_drop: $Last_Name_drop\n"
. "First_Name_drop: $First_Name_drop\n"
. "pos_drop: $pos_drop\n"
. "team_drop: $team_drop\n"
. "Last_Name_retain: $Last_Name_retain\n"
. "First_Name_retain: $First_Name_retain\n"
. "pos_retain: $pos_retain\n"
. "team_retain: $team_retain\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;


THIS IS THE PORTION OF THE SCRIPT AFTER I EDITED IT

//Sending Email to form owner
$pfw_header = "From: me@myemail.com\n"
  . "Reply-To: me@myemail.com\n";
$pfw_subject = "Retention Summary";
$pfw_email_to = "you@youremail.com";
$pfw_message = "Visitor's IP: $pfw_ip\n"
"$sflteam", "$Last_Name_drop", "$First_Name_drop", "$pos_drop", "$team_drop", "$Last_Name_retain", "$First_Name_retain", "$pos_retain", "$team_retain";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;



Share this post


Link to post
Share on other sites
Rather than have the script put the data in single lines like this:

cavaliers
jones
lb


I want it to put the values in a CSV line (in the body of the email) like this:

cavaliers, jones, lb

Share this post


Link to post
Share on other sites
well, if you can get all the records into an array, simply use implode() with commas as the delimiters to make a row. to make a CSV file, typically you'll need to change your content-type to text/plain or something similar and output newlines at the end of each row.

i'm not sure exactly what you're after here... any more explanation?

Share this post


Link to post
Share on other sites
try[code]
$pfw_message = "Visitor's IP: $pfw_ip\n"
."$sflteam, $Last_Name_drop, $First_Name_drop, $pos_drop, $team_drop, $Last_Name_retain, $First_Name_retain, $pos_retain, $team_retain";
[/code]

Share this post


Link to post
Share on other sites
Thanks all for the help.

This is the kind of output (in the body of an email) that I was after:

Visitor's IP: 65.243.45.100
DKN, Brown, J, Driver, OH, Green, A, Loader, PA

I tried sasa's example and that worked. Obsidian, I wasn't necessarily trying to create a CSV file, although someone is sure to ask for a CSV file next instead of the data in an email message, so thanks for that bit of advice.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.