I have one MySQL database field which saves comment from users. Some comments have new lines but when I try to use PHP to display the contents of the database, the new lines are ignored. I know about nl2br() but I guess it will not work as my users will not bear to write /n or /r/n or /r.

My column type is LONGINT and another problem is that if quotation marks exist in the comment, the comment doesn't get stored in the database.

I have more information to provide, I use textarea and use "POST" method.

I want reply as soon as possible.

Recommended Answers

another problem is that if quotation marks exist in the comment, the comment doesn't get stored in the database.

for this use addslashes($str);

Jump to Post

All 3 Replies

another problem is that if quotation marks exist in the comment, the comment doesn't get stored in the database.

for this use addslashes($str);

are your comment text?
The u can't store them in a longint. Just use TEXT as ur column type
If there are numerical i don't see the problem with new lines

I changed my column type to TEXT. Sorry my column's type was LONGTEXT before.
I have used nl2br in a different way and now it works :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.