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
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
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..
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$field = str_replace(array("\n","\r
nl2br replaces newlines into <br/>newlines, so therefor the newlines indeed wll not be actually removed to my knowledge.
-r-