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

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8

    Missing enters textfield


    hi,

    I have this form with a textarea. But when I store the text in the database, and retrieve it, the "enters" are gone. How can I fix this?
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,112
    Rep Power
    9398
    They're not gone, they just don't appear as newlines in HTML. Try outputting with nl2br (do it after HTML-escaping).
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8
    it works, thanks
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8
    oh should I use htmlspecialchars before, or after nl2br
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Before, obviously. Just as requinix said. Otherwise, all the <br /> will appear literally in the text.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    436
    Rep Power
    8
    Thanks I got now this, should be good:

    PHP Code:
    nl2br(htmlspecialchars($text)) 
    Thanks again
    Last edited by derplumo; July 16th, 2013 at 08:22 AM.

IMN logo majestic logo threadwatch logo seochat tools logo