www.webdeveloper.com
Results 1 to 4 of 4

Thread: htmlentities

  1. #1
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898

    htmlentities

    when storing data to our DB2 database, I am running out textarea's through PHP's htmlentities function, and when it store's things like <br /> in the database, it stores it as:

    Code:
    got it to work&lt;br /&gt; with &#039;quotes&#039;
    And then when it displays on a page, it shows up like this:

    [SIZE=small](got it to work<br

    How can I get it to not display the <br /> code, but display the line break?

    Thanks!
    [/SIZE]

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,245
    Well, option number 1 would be to not apply htmlentities() to it when you store it in the DB. (I don't just mean that facetiously: the database doesn't care if there are HTML tags in the data or not.)

    But if you are stuck with it that way, you can undo the "damage" with html_entity_decode().
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    yup, i removed the htmlentities, and since we are using DB2, couldn't use addslashes because the \ is not a valid escape character, so had to replace all single quotes with 2 single quotes.

    Now I have an issue, when I try to use double quotes, I'm storing the value in a hidden field on my confirmation screen, but when I have a value with double quotes, it's getting stripped from the sql, because it looks like this in the source of my confirmation screen:

    HTML Code:
    <input type="hidden" name="plusup_message" value="got it to work<br /> it's a miracle "yeah"">
    Notice the 2 double quotes at the end. Any suggestions on how to my double quotes to work, so that from my confirmation page, when I press my submit button, it sends the data correctly to my update page?

    Thanks for the help!

  4. #4
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    nevermind, I got it working, adding htmlentities to my hidden value when populating it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles