1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Rep Power
    i have a html text area that i'm inserting into a mySQL database. before it's submitted, i would like to allow formatting in that text area, so i want to replace all carriage returns with <br> tags.

    how can i do this?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Rep Power
    If your textarea is named summary
    then before your run your query
    $summary = nl2br($summary);
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Caro, Michigan
    Rep Power
    Just note that this doesn't "replace" the newlines with <BR>, it simply adds the <BR> in before the newlines. If you need them actually replaced, use something like this..

    $summary = str_replace("n","<BR>",$summary);

    The output will look the same in your browser no matter which method you use. It'll just change how your source code looks.

    ---John Holmes...

Similar Threads

  1. XHTML not allowing Transitional w/ PHP HTML
    By PFCritics in forum PHP Development
    Replies: 1
    Last Post: February 16th, 2004, 07:32 PM
  2. PHP script - back 2 html
    By JamieH in forum PHP Development
    Replies: 10
    Last Post: February 3rd, 2004, 08:59 AM
  3. Can php be used in html files
    By emzyme in forum PHP Development
    Replies: 3
    Last Post: January 29th, 2004, 01:50 PM
  4. all-in-one php script displaying html
    By emzyme in forum PHP Development
    Replies: 5
    Last Post: January 27th, 2004, 07:07 AM
  5. php n00b. Put a php file into an html template?
    By WorldBuilder in forum PHP Development
    Replies: 3
    Last Post: January 25th, 2004, 08:48 PM

IMN logo majestic logo threadwatch logo seochat tools logo