August 9th, 2000, 05:42 AM
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.
August 9th, 2000, 05:51 AM
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