writing into CSV from a web page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • learnPHP
    New Member
    • Mar 2008
    • 20

    #1

    writing into CSV from a web page

    HI,

    I have a few PHP pages. The pages have text boxes of variable sizes. when i enter data into the text boxes the data is written into a csv file. Each text box corresponds to one column in the csv. However the problem i am facing is that if i enter a comma (,) in anything that i write in a textbox then when it is written to a csv it gets converted into two texts that is data before the comma is in one column and data after the comma is in the next column where as it should all be under one column. How can i do this?? Right now i am simply reading the data from textboxes using GET Session variables.

    Thanks
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Itb really depends on what you have determined to be the field separator character to be. In your cose it appears to be a comma. You can go 2 ways abouit this.

    1. choose a different separator character, like a semi-column or a #.
    2. enclose all fields within single or double quotes. That way the separator char is within the quoted field and the CSV reader will treat it as 1 field.

    Ronald

    Comment

    Working...