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.

Parsing data to/from mysql database

  • 16-11-2006 02:43AM
    #1
    Closed Accounts Posts: 8,866 ✭✭✭


    I was wondering how difficult it is to do? I've written a small blog system for a personal website, nothing fancy at all, but I now need to know how to get it into and out of the database "as is", for example if I write a blog like:

    "The world is shít.

    We're all going to die."

    ...firstly I'd be weird... but more importantly, it would print out like this:

    "The world is shít. We're all going to die."

    How do I do things like maintain paragraphs, breaks, and even further along, allow for links and images? Cheers guys!


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Mirror wrote:
    How do I do things like maintain paragraphs, breaks, and even further along, allow for links and images? Cheers guys!
    By formatting it - essentially parsing the input and converting certain characters to HTML entities. The most basic formatting you can do is replacing carriage returns to <br/>'s or, better still, encapaulating your paragraphs in <p></p>'s. Additionally you'd want to look at other entities, such as &, € and the like.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Any good tutorials out there on how to do this? I haven't done much string manipulation so I wouldn't even know where to start.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Mirror wrote:
    Any good tutorials out there on how to do this? I haven't done much string manipulation so I wouldn't even know where to start.
    Depends upon the language you're coding in. I suggest you use Google.


  • Registered Users, Registered Users 2 Posts: 378 ✭✭sicruise


    Generally the end of line character is \n so you can replace this with <br/>


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I'm using PHP, and the input is just a textarea, which I want to be pretty much a WYSIWYG editor.


  • Advertisement
  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Mirror wrote:
    I'm using PHP, and the input is just a textarea, which I want to be pretty much a WYSIWYG editor.
    Then I suggest that you use a third party client-side plugin like the FCKeditor.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Thats the trick, nice one Corinthian! ;)


Advertisement