I am wanting to store user messages in a database. I have read many sites/posts about what would be the correct way of going about this.

There are advocates that say "Write in BBC, parse into HTML and then store" and then there are others that say "Write in BBC and store, then parse into HTML when displaying" and others who just shout "Write and store in HTML but make sure you sanitize"

These are good arguments but which is easier to implement.

I have played with different options and see the good points but do hit obstacles.

So for me to get users to write messages in BBCode is the sensible thing but what to do next.

I need to store the message but I also need to ability to redit the messages at a later time.

Writing and storing as BBC makes the editing process so much easier as no conversion is required.

For extra guidance I looked at how SMF stored it's messages and they are stored at HTML, so the user inputs as BBC and SMF then parsers the BBC into HTML for storing. If a user wishies to edit his message SMF must parser HTML back into BBC.

So I am confused to say the least as to what is a good way. First off if I store as HTML then I need a way to parse into BBC for editing.

I am using nbbc for BBC to HTML parseing but I can not find a good HTML to BBC parser.

Can anyone point me to a parser that can do the HTML to BBC or even both conversions.

    Hate to reply to my own message but would like to say that the parser should be XHTML 1.0 Strict if possible

      To save as BBCode makes it easy to edit.
      To save as HTML can make it faster to display posts.

      To store as BOTH will make bigger database.
      Would be like having a HTML Cached version.

      There are advantages with both.
      But myself would go for storing as BBCode
      and convert to HTML at the display.

      I found this nice jQuery editor yesterday: markItUp
      It has BBCode or XBBCode as addon Sets
      http://markitup.jaysalvat.com/downloads/

        halojoy;10939709 wrote:

        To save as BBCode makes it easy to edit.
        To save as HTML can make it faster to display posts.

        To store as BOTH will make bigger database.
        Would be like having a HTML Cached version.

        There are advantages with both.
        But myself would go for storing as BBCode
        and convert to HTML at the display.

        I found this nice jQuery editor yesterday: markItUp
        It has BBCode or XBBCode as addon Sets
        http://markitup.jaysalvat.com/downloads/

        Thanks for the URL.

        Yes, inputing and storing as BBC into MYSQL is what I think I shall do. It does give me the ability to push the data back to the user for re-editing without having the difficult job of reparsing.

        I also noticed that I still have to run HTMLSpecialChars across the data before storing to escape the quotes.

          Pigmaster;10939812 wrote:

          Thanks for the URL.

          Yes, inputing and storing as BBC into MYSQL is what I think I shall do. It does give me the ability to push the data back to the user for re-editing without having the difficult job of reparsing.

          I also noticed that I still have to run HTMLSpecialChars across the data before storing to escape the quotes.

          I am not sure you need to run [man]htmlspecialchars[/man] before insert in MYSQL.
          But sure run [man]mysql_real_escape_string[/man] of course.
          Usually htmlspecialchars is what should be used right before DISPLAYING stuff.

          echo htmlspecialchars($text);

          Did you notice that markItUp editor not only has addons for generating BBCode
          but also a BBCode Parser to decode bbcode
          http://markitup.jaysalvat.com/downloads/

          markItUp! Php BBCode Parser
          By Jay Salvat - Jun, 21 2009

          markItUp! BBCode parser V.1.0.5

          | Download from there |

            halojoy;10939826 wrote:

            I am not sure you need to run [man]htmlspecialchars[/man] before insert in MYSQL.
            But sure run [man]mysql_real_escape_string[/man] of course.
            Usually htmlspecialchars is what should be used right before DISPLAYING stuff.

            echo htmlspecialchars($text);

            I am currently using

            filter_var($This_Variable, FILTER_SANITIZE_STRING);

            which I have been told is better than mysql_real_escape_string

            Did you notice that markItUp editor not only has addons for generating BBCode
            but also a BBCode Parser to decode bbcode
            http://markitup.jaysalvat.com/downloads/

            Yes I did, it had a few parsers there plus the newer xBBCode

              Write a Reply...