#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Replace /n with <br>, but only once...


    Hi All, Developed some code to enable users to edit a webpage. Newlines are replaced with <br>. It works fine the first time. The problem is that the users can come back and update their comments - using the code below. And for some reason I end up with double <br> <br>. and probably triple on the next edit, etc. Any thoughts?

    Thanks in advance,

    <cfquery name="InsertCompany"
    datasource="#Request.InventoryDSN#"
    username="#Request.username#"
    password="#Request.password#">
    UPDATE Reports
    SET
    Comments = <cfif Len(Trim(Form.Comments)) GT 0>
    '#ReReplace(Form.Comments, "\n", "<br>", "ALL")#'
    <cfelse>
    NULL
    </cfif>
    WHERE
    ReportNumber = #ReportNumber#
    </cfquery>

    <cflocation url="ReportList.cfm">
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0
    Nevermind, I got it. Just stripped out the <br>s when they pull their comments from the DB.

    Thanks anyway!

IMN logo majestic logo threadwatch logo seochat tools logo