#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Arizona
    Posts
    56
    Rep Power
    15

    Decoding and textareas


    Hello,

    I am having trouble moving characters between a textarea and a database.

    Say I write the following in a <textarea> of a form:

    Code:
    <p>This is a multiplication symbol: &amp;times;</p>
    I submit it to the db without any encoding. Now when I echo the entry back into a new <textarea> I see this:

    Code:
    <p>This is a multiplication symbol: </p>
    What I want is for the new <textarea> to display exactly what is in the db. I have tried using htmlspecialchars() and htmlspecialchars_decode(), both together and separately, but I never get the result I want. Can anyone suggest a way to do this? Thanks.
    Last edited by ebakunin; April 8th, 2010 at 09:01 AM. Reason: character encoding problems
  2. #2
  3. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1171
    What's the charset used in the database? The one you use in your document? Be consistent and use the same character set, e.g. UTF-8 in both places.

    Comments on this post

    • ManiacDan agrees : Simply for STILL having that quote in your sig.
    "Seriously, we're not a search engine, we're actual people." ~ ManiacDan

    BookMooch.com : Give books away. Get books you want.
  4. #3
  5. Web Developer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Posts
    481
    Rep Power
    117

    Thumbs up


    Originally Posted by ebakunin
    Hello,

    I am having trouble moving characters between a textarea and a database.

    Say I write the following in a <textarea> of a form:
    Code:
    <p>This is a multiplication symbol: &times;</p>
    I submit it to the db without any encoding. Now when I echo the entry back into a new <textarea> I see this:

    Code:
    <p>This is a multiplication symbol: </p>
    What I want is for the new <textarea> to display exactly what is in the db. I have tried using htmlspecialchars() and htmlspecialchars_decode(), both together and separately, but I never get the result I want. Can anyone suggest a way to do this? Thanks.
    Try with htmlentities()
    I will try my best !!!
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Arizona
    Posts
    56
    Rep Power
    15
    Just realized the encoding problem struck again in my original post. Feh. I've updated the original post which should now make a lot more sense. Thanks so much for the help!
    Last edited by ebakunin; April 8th, 2010 at 09:06 AM.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,884
    Rep Power
    6356
    try it with html_entity_decode, or htmlentities, however you want it to be shown.

    You shouldn't be storing HTML entities in your database.

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo