You are here: Re: Error creating CSV out of SQLdb « All PHP « IT news, forums, messages
Re: Error creating CSV out of SQLdb

Posted by Curtis on 12/09/05 02:52

ND <daantje_l@hotmail.com> wrote in message
news:4396d617$0$88080$dbd41001@news.wanadoo.nl...
> Hi,
> I have the following coding problem:
>
> I have a evaluation form with some questions.
> Some of these questions are answered by a textarea (which
gives the user the
> possibillity to use [enter] and make a new line feed in
the answer).
> The answers are recorded into a database.
>
> This all works fine, but!
>
> When I want to output my answers to a .csv file, the 'new
line feeds' of the
> textarea fields are messing up my grid in the csv (excel
text file seperated
> by semicolon ';').
> I write the answers to a file which can be downloaded but
the 'new line'
> makes an abrupt stop to a line.
>
> Hope somebody understands the problem.
> How can I work around this 'little' error?
>
> I've tried the following without any results :-(
>
> $value=ereg_replace('\r\n','',$value);
> $value=ereg_replace('\r','',$value);
> $value=ereg_replace('\n','',$value);

$text = str_replace("\r", "", $text);
$text = str_replace("\n", "", $text);

Should zap everything in the block of text, Daniel. No need
to do any combinations (as in your first line) if you're
disposing of both characters anyway.


> I'm guessing that since there is no actual \n to be found
in the $value
> field it does not replace anything.
>
> the nl2br function DOES however recognize the \n but it
keeps the \n in the
> text:
> a combination where \n is replaced by <br /> which is
deleted in step2:
>
> $value=nl2br($value);
> $value=ereg_replace('<br />','',$value);
>
> But I still get the 'new lines' in my output file. I don't
want this!! I
> want one continued file with info....

Unless there's something I'm failing to grasp about what's
actually messing up your output, the str_replace()s should
do it. You are talking about processing the text out of the
textarea BEFORE it hits the database, aren't you?

--

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация