SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 27 of 27

Thread: Edit Error

  1. #26
    SitePoint Enthusiast sarahG's Avatar
    Join Date
    Apr 2006
    Location
    Wirral, UK
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I presume you're running the nl2br before you're saving the information in the table? The trouble is once you start doing this you need to realise that every new line will be assigned a br tag. All you are doing is saving the text being run through the nl2br, but I'm presuming you're not running the content through a function like br2nl beforehand (no the function doesn't exist but you get the idea). So on each save the br tags are being added, but on each retrieval they're not being removed, but save again, and the tags will most likely double up. You're assuming the content is saved with no br tags, the trouble is after the first save they have the br tags in place.

    the best option is to remove the nl2br and either
    1. always save your reviews with (x)html displayed and just display the output and allow your html to control it
    or
    2. use nl2br on the front end when retrieving the information, not when saving the information.

    Alternatively write a function to strip out the <br />s before displaying the text in your edit form, then when you resave it will save them back in.

  2. #27
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how can i use nl2br on the front end in the xhtml code?

    Thanks

    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •