Jump to content

Want to Change Output to CSV


kc27

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: [email protected]\n"
  . "Reply-To: [email protected]\n";
$pfw_subject = "Retention Summary";
$pfw_email_to = "[email protected]";
$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: [email protected]\n"
  . "Reply-To: [email protected]\n";
$pfw_subject = "Retention Summary";
$pfw_email_to = "[email protected]";
$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 ) ;



Link to comment
https://forums.phpfreaks.com/topic/19931-want-to-change-output-to-csv/
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?
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.

Archived

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

×
×
  • Create New...

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.