Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:41:39+00:00 2026-06-17T18:41:39+00:00

I got problems in creating a csv file because if my data contains ,

  • 0

I got problems in creating a csv file because if my data contains , it will be splitted into parts and put it in other columns that destroys my csv file.

Here is the sample output:

Sample output link

As what you can see the first row in TITLE column should have this data "Acer Aspire AS5250-0639 15.5" Laptop (1.65 GHz AMD Dual-Core Processor E-450, 4 GB RAM, 500 GB Hard Drive, DVD+/-RW Optical Drive, Windows 7 Home Premium 64-bit)" starting in 4 GB RAM it is splitted and put it in other columns because before it it has , and more.

As of now here is my PHP script:

    <?php
include 'database.php';
$db = new database();

$data = $db->exportdatabase();

$out = '';
$out .= 'GSEQ,BRAND,TITLE,SIMAGE,SPRICE,WEIG,DIMENSIONS,ASIN,CATEGORYNAME,MODELNO';
$out .="\n";

foreach($data as $items){
    $out .=' '.$items['GSEQ'].', '.$items['BRAND'].', '.$items['TITLE'].', '.$items['SIMAGE'].', '.$items['SPRICE'].', '.$items['WEIG'].', '.$items['DIMENSIONS'].' 
    '.$items['ASIN'].', '.$items['CATEGORYNAME'].', '.$items['MODELNO'].'
    ';
    $out .="\n"; 
    //var_dump($items);
}

header('Content-Description: File Transfer');
header("Content-Type: application/csv") ;
header("Content-Disposition: attachment; filename=Data.csv");
header("Expires: 0");
echo $out;
exit;   
?>

How can I possibly fix this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:41:40+00:00Added an answer on June 17, 2026 at 6:41 pm

    For starters I would stop trying to do something yourself that PHP can do for you. Use fputcsv instead of doing it yourself: http://php.net/manual/en/function.fputcsv.php. This method also deals with escaping your delimiter ( your comma ).

    On top of that.. dont use ‘,’ as your csv seperator. You are probably better off using ‘|’ as a seperater, since that character is way less common.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got problems starting my WAR application on a local JBoss. After two other
I am creating a plugin and got something problems: in the case: I have
I got some problems when creating a Cairo::RefPtr on a Cairo-Context. I really can't
I'm learning ASP.MVC now. I got some problems of creating strong-typed view. I added
I've got problems with running a powershellscript from different locations (c# application, webservice...). I
got some problems. Built an applet that has to be used step-by-step. After each
got some problems deploying a java web application on jboss 7.1... Stepped through the
I got some problems here, I can't make my find_by_sql request to render an
I got some problems in Datagrid WPF I have a datagrid, and I want
i got some problems with my history listview. on logcat it stated the cause

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.