Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

text from textarea loses spacing when written to db....

  • 20-07-2005 10:09PM
    #1
    Registered Users, Registered Users 2 Posts: 252 ✭✭


    Hi,

    Im submitting text from a textarea in a HTML form which is written to a db.
    The text will be seperated into paragraphs (ie hitting enter between lines).
    However when i read it back from the db none of the spacing is held.

    I know there are rich text editors i can use on the textarea but I dont what to give the user the options that come with those editors.

    Does anyone know how i can write the info to the db (MySQL) so as it holds the spacing?

    Tnx


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    You've left out even the most basic details, such as what scripting language you're using, how the data is being written and read back, etc. This isn't the first time either. Please think before you post, don't just jot down a vague issue and hope that someone pull the facts out of midair.

    (But assuming you're using PHP, there's absolutely no reason why the line breaks would be removed unless something in the script is removing them. At a guess I'd say you're trying to print plaintext without converting the line breaks to HTML, with nl2br() for example.)

    adam


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Are you outputting to HTML, or back into the textbox?

    If HTML, replace all line breaks with <p /> before you neter the text into the database.
    If to the textbox, replace with /r/n, or, if on PHP, use nl2br().

    Failing that, just output the whole thing into a pre tag.


  • Registered Users, Registered Users 2 Posts: 252 ✭✭ConsultClifford


    or, if on PHP, use nl2br().

    Tnx Aidan

    Up the kingdom! :D


Advertisement