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 the mysql server as one line?!
I am using PHP and mysql.
Many thanks
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 the mysql server as one line?!
I am using PHP and mysql.
Many thanks
MySQL should preserve the newline - could it be your output (or your mysql gui) that isn't displaying it?
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.
When you output the field from the database to an html document, either use <pre>
or nl2br()
(or a <textarea>
).
very neat, but will this saves javascript as well too? will this cause CSS attack?
tq