Jump to content


Photo

Want to Change Output to CSV


  • Please log in to reply
5 replies to this topic

#1 kc27

kc27
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 September 2006 - 06:05 PM

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 ) ;





#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 06 September 2006 - 06:14 PM

What are you trying to do in the second example?

#3 kc27

kc27
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 September 2006 - 06:49 PM

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

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 06 September 2006 - 06:51 PM

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?
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 06 September 2006 - 07:35 PM

try
$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";


#6 kc27

kc27
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 September 2006 - 08:04 PM

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users