Jump to content


Photo

Empty lines when creating file downlod


  • Please log in to reply
No replies to this topic

#1 wheelz

wheelz
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 20 July 2006 - 09:07 AM

Hi

I've been struggling with a problem now for a couple of weeks and was wondering if anyone could help.

Basically, I'm trying to create a file which will be used for batch processing of credit card purchases.

The file is downloading fine but always has two empty rows at the top.

I've tried a nimber of diffeent ways to remove the blank rows but it keeps happening.

Here is the code in question.

case 'create_batch':

  if ($HTTP_POST_VARS['saveas']) {  // rebound posted csv as save file
  $savename = $HTTP_POST_VARS['saveas'] . ".csv";
  } else {
    $savename='unknown.csv';
      }
   
if ($HTTP_POST_VARS['notProc']) {
    foreach ($notProc as $value) {
           
    $create_file_query = tep_db_query("select o.orders_id, o.cc_owner, o.cc_number, o.cc_ccv, o.cc_expires, o.currency, o.currency_value, c.value as rand_value, ot.value as order_total from " . TABLE_ORDERS . " o, " . TABLE_CURRENCIES . " c, " . TABLE_ORDERS_TOTAL . " ot where o.orders_status = 1 and c.currencies_id = 4 and ot.orders_id = o.orders_id  and ot.class = 'ot_total' and o.orders_id = " . $value . " order by o.orders_id ASC");
   
    $file = tep_db_fetch_array($create_file_query);
   
    $amt = $file['order_total'] * $file['rand_value'];
        $conversion = number_format($amt,2);
        $remcomma = str_replace(',','',$conversion);
        $total = str_replace('.','',$remcomma);
   
        $csv_accum = "A," . $file['orders_id'] . "," . $file['cc_owner'] . "," . cc_decrypt($file['cc_number']) . "," . cc_decrypt($file['cc_expires']) . ",00," . cc_decrypt($file['cc_ccv']) . "," . $total . "\n";
       
      $size = strlen($csv_accum);
    header("Last-Modified: " . gmdate('D,d M Y H:i:s') . ' GMT+2');
    header('Pragma: private');
    header('Cache-control: private, must-revalidate');
    header("Content-Type: text/comma-separated-values");
    header("Content-Disposition: attachment; filename=$savename; size=$size");
    echo $csv_accum;
    //tep_db_query("update " . TABLE_ORDERS . " set orders_status = '7', last_modified = now() where orders_id = '" . $value . "'");
    }
    exit;
    }
    break;

I've tried str_replace and trim, but nothing seems to make a difference.

I don't know if anyone will be able to help without seeing the code in action but I thought it's worth a try.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users