Jump to content


Automatic breaks in MySQL data?


3 replies to this topic

#1 greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 01 December 2006 - 11:03 PM

If anyone can give me the solution to this, I'd greatly appreciate it:

I have a form that adds a row to a MySQL table, and then I echo that row on a page. One of the things in the form is a text field, where I'm planning to insert long articles with several paragraphs.

The issue is that if I simply press the "Enter" key on the keyboard to make line breaks in the text area, the MySQL doesn't recognize it as a line break, and thus echoes the entire article as one long paragraph.

How can I make it recognize line breaks?

Thanks in advance for any help.

#2 greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 01 December 2006 - 11:19 PM

Ugh, should've spent a little more time searching before asking. I found the solution: http://zulumonkey.org/?id=tutorials&pa...ment&oid=36

Well, hopefully this'll be useful to someone else who's been wondering the same thing.

#3 Trix06

    Young Padawan

  • Members
  • Pip
  • 292 posts
  • Gender:Male
  • Location:NSW Australia
  • Interests:Web Design & Development, Graphic Design, Programming, Networking, Girls, The Beach, Amatuer Radio Communications and more.

Posted 02 December 2006 - 12:26 AM

Intergrate a editor eg tinymce or FCKeditor :) That should work!

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 02 December 2006 - 01:55 AM

Considering it's the fact that all mySQL sees and stores exactly what you tell it to, it's not that it doesn't recognize the "enter" key, it's that the enter key sends a newline "\n" character. So if you viewed the source, the breaks would be there, but html ignores whitespace unless you use a <pre> tag, or use css - white-space:pre; There is also the uber-simple php str_replace("\n", '<br>', $text);

In short, using FCKeditor would be a huge waste of time and bandwidth unless he's planning on going full WYSIWYG on this textarea.

And this topic was technically solved, so both of these last two posts were pretty pointless :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users