1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Saving \n as <br> to database

Discussion in 'PHP' started by qwikad.com, Oct 21, 2015.

  1. #1
    I tried this but it's not chaning new lines to <br>
    
    <textarea name="addesc" id="addesc"><?php echo $data['addesc']; ?></textarea>
    
    Code (markup):
    
    $data['addesc'] = preg_replace("/\r\n|\r/", "<br />", $_POST["addesc"]); $data['addesc'] = trim($data['addesc'])
    
    Code (markup):
    As such there's no $_POST["addesc"] on the post.php page. There's $_POST["do"]. I tried it too. No results.

    I am sure I am missing something. How is something like that done exactly?
     
    Solved! View solution.
    qwikad.com, Oct 21, 2015 IP
  2. #2
    ThePHPMaster, Oct 21, 2015 IP
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #3
    This did it:
    $data['addesc'] = htmlentities(nl2br($data['addesc']));
    Code (markup):
     
    qwikad.com, Oct 22, 2015 IP