Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 46

Thread: Comments box

  1. #11
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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

  2. #12
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    OO opss, trim takes out line breaks as well. Try it like this

    PHP Code:
    $comment mysql_escape_string (trim (nl2br($_POST['comment']))); 
    Corrections to my coding/thoughts welcome.

  3. #13
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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?

  4. #14
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    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>' ); 
    Corrections to my coding/thoughts welcome.

  5. #15
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Thanks Blue Walrus, One question, why do you have to put in the dots?

  6. #16
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Also if I wanted to make $username bold how would I put in the <b> tags into this code

    PHP Code:
    $cheese =  "$username  - $comment  "

  7. #17
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    The periods concatenates it together.

    I think this should do it...

    PHP Code:
    $cheese =  "<b>$username</b>  - $comment  "
    Corrections to my coding/thoughts welcome.

  8. #18
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Thanks you blue walrus. I added in the bold tags but it is making the entire thing bold not just $username

  9. #19
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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.

  10. #20
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •