开发者

Why entered key word is not store in database?

开发者 https://www.devze.com 2022-12-29 19:51 出处:网络
I had made on form, in which i had one text area. Now i am storing that data of text area to mysql database.

I had made on form, in which i had one text area.
Now i am storing that data of text area to mysql database.

Now if i had press enter key word then it not stores in the database.

Because i don't get exacted output as what i entered.

as example...

If i had write like this.....

Good

Morning

How are you?

then i only get like this...

Good Morning How are you?

So i开发者_如何学JAVAts not storing that enter key word in the database.


You should convert the textarea content with nl2br then store it.

It will convert your newlines to <br />


My guess is you are outputting HTML which doesn't render line breaks. Try using nl2br().


I am sure the \n character is stored in the database. However it wont be rendered if you display the output on a web page. Just replace \n with <br >


If you are displaying your stored text as HTML then \n are getting ignored. PHP has nl2br() function that would convert linebreaks to <br>, just run your text through it before displaying.

0

精彩评论

暂无评论...
验证码 换一张
取 消