Jump to content

davidb2002

Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

davidb2002's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a script that uses fopen to open a csv file, replace the text within it with 2 lines. Then we use PHPMailer to send the file as an attachement via email. Doing this, the csv only contains about 1/4th of the content, yet when I view the csv file on the server, it contains all the information. If I just attach without the fopening and all, it attaches the full file. So I thought that it might be a timing issue, maybe i was attaching the file before php could complete writing to it, so I paused it for 5 seconds, then 10 seconds, no progress, it still stops at the same point. Can anyone explain what is going on? Here is the coding: [code]     $headerline = '"slno","trackingCode","currdate","currtime","referField","amtRequired","loanPurpose","fName","mName","lName","dob","maritalStatus","empStatus","postCode","address","area","town","hlongyears","hlongmonths","hometype","telephone","mobile","wnumber","email","contacttime","numbpref","jointapplication","occupation","grossincome","s2pcode","s2address","s2area","s2town","s2empstatus","s2occupation","s2grossincome","s2houseworth","s2mortage","s2findus","s2ppi","s2fName","s2mName","s2lName","s2dob","s2empstatus1","s2occupation1","s2grossincome1","firstAppEmpName","secondAppEmpName","firstAppEmpAddr","secondAppEmpAddr","firstAppEmpNo","secondAppEmpNo","firstAppEmpDur","secondAppEmpDur","firstAppPrevEmpName","secondAppPrevEmpName","firstAppPrevEmpAddr","secondAppPrevEmpAddr","firstAppPrevEmpDur","secondAppPrevEmpDur","bankName","bankAddr","hlYears","hlMonths","children","mrp","mct","chkCredit","type1","name1","amount1","monthlypymt1","settle1","type2","name2","amount2","monthlypymt2","settle2","type3","name3","amount3","monthlypymt3","settle3","type4","name4","amount4","monthlypymt4","settle4","loan_archive","loan_delete","stageform","app_status","app_lock","call_attd","app_stat_feed","app_attd_date","addn_addr","ppi","addn_info","app_attd_time","app_comp_stat","loanTerm","keywords"';     $headerline = $headerline."\r\n";     $norton = mysql_query("SELECT * FROM email WHERE lender='Nor'") or die(mysql_error());     $nrow = mysql_fetch_array($norton);     $ncount = $nrow['count'];     $number = $ncount + 1;     mysql_query("UPDATE email SET count='$number' WHERE lender='Nor'") or die(mysql_error());     $ndate = date("d/m/y");     $ntime = date("H:i:s");     $entry_line = '"'.$number.'","test","'.$ndate.'","'.$ntime.'","","'.$amount.'","'.$reason.'","'.$name.'","","'.$surname.'","'.$dob.'","'.$marital.'","'.$empstatus.'","'.$postcode.'","'.$addline1.'","'.$addline2.'","'.$addline3.'","","","homeowner","'.$homephone.'","'.$mobilephone.'","'.$workphone.'","'.$email.'","","","","'.$occupation.'","'.$monthlyincome.'","","","","","","","","'.$propvalue.'","'.$mortout.'","","","","","","","","","","","","","","","","'.$emptime.'","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","new","","","","","","","","","","0",""';     $content = $headerline.$entry_line;     //add header line to csv     $fp = fopen("export.csv", "w");     fputs($fp, $content);     fclose($fp);      require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsMAIL(); // telling the class to use SMTP $mail->From = "mu@email.com"; $mail->AddAddress("my@email.com"); $mail->Subject = "Test CSV"; $mail->Body = "This is a test CSV"; $mail->WordWrap = 50; $filename = $number.".csv"; $mail->AddAttachment("export.csv"); if(!$mail->Send()) {    echo "Message was not sent";    echo "Mailer Error: " . $mail->ErrorInfo; } else {    echo "Message has been sent"; } [/code]
×
×
  • 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.