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

    Join Date
    Jul 2000
    Posts
    18
    Rep Power
    0
    I'm having a problem that probably is pretty easy to solve, but I just can't figure it out.
    I'm running a standard database for adding articles into MySQL, and articles added into the database are nl2br'ed. This works fine.
    But there is also an option for editing the article, where it is loaded inside a textarea (form). When this in turn is being replaced into the db it is also nl2br'ed to account for new linebreaks. But unfortunately the linebreaks allready there are doubled.
    How can I avoid doubling the existing breaks, only adding the new ones.

    Hope this made sense.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    14
    don't nl2br on insert, only nl2br when displying on the screen (i.e. reading the news)

    so when the user edits, they see what they originally added, with no nnnn problems

    or read up on regular expressions and do an ereg_replace() for *more* than 2 n's in a row back to nn

    htht

    bealers

    ------------------
    http://back-end.org

Similar Threads

  1. inserting multiple email address from a textarea
    By mrkgrav in forum PHP Development
    Replies: 17
    Last Post: September 24th, 2004, 06:28 PM
  2. textarea problem (not the usual "html" stuff)
    By Terragen in forum PHP Development
    Replies: 6
    Last Post: November 30th, 2003, 12:05 PM
  3. Graying out a textarea
    By spideyyy in forum HTML Programming
    Replies: 6
    Last Post: November 19th, 2003, 10:40 AM
  4. Textarea line breaks using <br>
    By bekin in forum PHP Development
    Replies: 11
    Last Post: October 2nd, 2003, 10:09 PM
  5. HELP! How to count longest word in a textarea
    By gijs24 in forum Java Help
    Replies: 1
    Last Post: July 31st, 2003, 07:29 AM

IMN logo majestic logo threadwatch logo seochat tools logo