Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

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

Options
  • 20-07-2005 10:09pm
    #1
    Registered Users 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 Posts: 252 ✭✭ConsultClifford


    or, if on PHP, use nl2br().

    Tnx Aidan

    Up the kingdom! :D


Advertisement