开发者

Saving new lines in a textfield to mysql field

开发者 https://www.devze.com 2022-12-18 10:46 出处:网络
Quick and simple (I hope) question; If a user inputs new lines in a text field, ie: 43 Dennis Beeston How can I save the new line rather than have it transferred to 开发者_JAVA百科the mysql server

Quick and simple (I hope) question; If a user inputs new lines in a text field, ie:

43 Dennis

Beeston

How can I save the new line rather than have it transferred to 开发者_JAVA百科the mysql server as one line?!

I am using PHP and mysql.


When you output the field from the database to a html document, either use <pre> or nl2br() (or a <textarea>).


To save the newlines in the database, take a look at mysql_real_escape_string

If you want your newlines displayed as breaks on the page when you display the records, use nl2br.


MySQL should preserve the newline - could it be your output (or your mysql gui) that isn't displaying it?

0

精彩评论

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