Saving new lines in a textfield to mysql field
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?
精彩评论