I changed the code but the comments are still displaying like this
Comment1
Comment2
Comment3
Comment4
Comment5
when I would like them to display like this
Comment1
Comment2
Comment3
Comment4
Comment5
Any help would be great
Printable View
I changed the code but the comments are still displaying like this
Comment1
Comment2
Comment3
Comment4
Comment5
when I would like them to display like this
Comment1
Comment2
Comment3
Comment4
Comment5
Any help would be great
OO opss, trim takes out line breaks as well. Try it like this
PHP Code:$comment = mysql_escape_string (trim (nl2br($_POST['comment'])));
Thankyou, it all works now. I also added in an extra feature so that it puts their username before their post. I have a question. Can you use <b> </b> tags inside php code?
You can use any html in PHP you just need to enclose it correctly. PHP generates the code (HTML, css, js, etc.) you want. So for example say you wanted your comments bold...
PHP Code:$comment = mysql_escape_string ( '<b>' . trim (nl2br($_POST['comment'])) . '</b>' );
Thanks Blue Walrus, One question, why do you have to put in the dots?
Also if I wanted to make $username bold how would I put in the <b> tags into this code
PHP Code:$cheese = "$username - $comment ";
The periods concatenates it together.
I think this should do it...
PHP Code:$cheese = "<b>$username</b> - $comment ";
Thanks you blue walrus. I added in the bold tags but it is making the entire thing bold not just $username
And one other question. When you enter a new comment into the box it is displayed right down the bottom of all the comments. Is their a way to make the newest comment display at the top? Thankyou everyone, for all your help.
Oou, and one more,
PHP Code:$sql = mysql_query ("INSERT INTO comments (id,comments,date,ip) VALUES ('0','".$cheese."','".$date."','$_SERVER['REMOTE_ADDR']';
it's causing this error
( ! ) Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Documents and Settings\Owner\Desktop\canberra amatuer productions\www\Canberra Amatuer Productions\echo time.php on line 59