Jump to content

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/15115-empty-lines-when-creating-file-downlod/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.