Displaying data from MySQL
Posted 27 March 2006 - 09:58 PM
I have written a guestbook in PHP using MySQL. When I write the message to the database I use "mysql_real_escape_string" to convert the string.
This is my problem. When I display the info from the database (using echo) it does not display new lines.
e.g. someone signs guestbook with:
My name is Fred,
My output is:
Hello, My name is Fred, Great site.
How do I get the '\n or <br> chars in there?
Posted 27 March 2006 - 11:55 PM
$comment = str_replace("\n", "<br />", $comment);
Thats just guessing you are using something like comment for your variable, just change it to what ever you are using and it should work, let us know how you get on.
Posted 28 March 2006 - 12:12 AM
this converts all \n's to <br>'s
Posted 28 March 2006 - 07:35 AM
Posted 28 March 2006 - 09:41 AM
If you cant find anythink then just post here and we will help!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users