How to remove <br />

Discussion in 'PHP' started by dramiditis, Dec 1, 2008.

  1. #1
    Hi there:
    I have a comment script and when people write something in goes to MySql database and after that when I display that text I have "<br />" on the plase where the user have pressed "enter".
    I'm using "addslashes(htmlspecialchars($comment))" to ad the comment to database.
    example http://www.eboras.se/annons.php?v=118
    Any sugestions?


    Thanks
     
    dramiditis, Dec 1, 2008 IP
  2. ariefsyu

    ariefsyu Active Member

    Messages:
    192
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    use
    str_replace("<br />", "", $your_comment_var);
    Code (markup):
    you may also need to look at this http://php.net/str_replace

    arief
     
    ariefsyu, Dec 1, 2008 IP
  3. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #3
    Without seeing the script I can only ask,

    Are you using striptags? This will strip all <tags> but you can allow some with additional parameters.
     
    Colbyt, Dec 1, 2008 IP
  4. misbah

    misbah Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #4
    use this
    $comment = str_replace('<br />', "\n", $comment);
    PHP:
     
    misbah, Dec 1, 2008 IP
  5. dramiditis

    dramiditis Peon

    Messages:
    87
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for all suggestions. Yes "str_replace" is the best solution. I alredy use "str_replace" for "bad words", but I have totally forgot. Stupid me ha?

    Thanks one more time.
     
    dramiditis, Dec 2, 2008 IP