Solved

storing textarea field into db without carriage return

Posted on 2004-09-24
6
425 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
ID: 12140640
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
ID: 12140680
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
ID: 12140698
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to send multiple emails at the same time in PHP 12 58
MySQL  on Tomcat 8 45
PHP: concatenate query 13 67
mysql update statement 3 22
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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