Solved

storing textarea field into db without carriage return

Posted on 2004-09-24
6
419 Views
Last Modified: 2012-06-27
Dear All,

I have a html form with a textarea for input. The data submitted would be sent to mysql db, I found that the textarea input cannot be stored properly to db if user press "enter" to make a new line...

I would like to replace the carriage return (/n/r) with  a space, but it does not work..I also tried the nl2br function, but the carriage return still exists...

it messes up my csv file outputed by php.. so how can I remove the carriage return from the input?

Thanks
0
Comment
Question by:esther_6694
  • 2
6 Comments
 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
You could try

$field = str_replace(array("\n","\r"), array('\n','\r'), $field);

nl2br replaces newlines into <br/>newlines, so therefor the newlines indeed wll not be actually removed to my knowledge.

-r-
0
 

Author Comment

by:esther_6694
Comment Utility
thanks, but it does not work..

in mysql, I can see a long space at the carriage return position and it makes the data can only be shown in 2 line for a row of record..



0
 
LVL 49

Accepted Solution

by:
Roonaan earned 100 total points
Comment Utility
You want it to be totally removed at all?

Then the line below should do the trick:

$field = str_replace(array("\n","\r"), array('',''), $field);

-r-
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now