Link to home
Start Free TrialLog in
Avatar of esther_6694
esther_6694

asked on

storing textarea field into db without carriage return

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
Avatar of Roonaan
Roonaan
Flag of Netherlands image

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-
Avatar of esther_6694
esther_6694

ASKER

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..



ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial