[PHP / MySQL]: Is there a way to store Rich Text in a MySQL table?

I gave en Entry Form the user to enter the values ​​that are stored in a MySQL table. There is one Project Information column in which the user can enter up to 200 characters, and this column is of type varchar.

Everything is fine so far. The problem starts when the project details contain multiple dots that need to be quoted on the HTML page like:

(1) .........
(2) .........
(3) .........

It is unclear if the project information contains one line, one paragraph, plain text, or a numbered list.

Is there a way to save the project details in a formatted text format in a MySQL table, and when PHP shows a page on my site, the text will be displayed as an insert?

+2


source to share


5 answers


If you want to keep something like rich text, you probably want to put it in a BLOB field: http://dev.mysql.com/doc/refman/5.0/en/blob.html which has no valid character set. assigned to him



May I ask why you would like to do this? Why not use one of the many text editors that convert your information to HTML (like tinyMCE ), which from there can be saved as - or passed through an Html-> Textile filter or something similar.

+4


source


You might want to use a simple markup language like Markdown or Textile . They allow you to get the natural look of plain text and then render it as HTML.



Otherwise, you can just display the text verbatim in tags <pre>

.

+3


source


If you are really using RTF you might want an RTF-to-HTML-Converter, a quick search led to this: http://directory.fsf.org/project/rtf2html/ (untested). Is this what you mean?

Which code you store in the MySQL database is up to you, but Varchar is probably not the best field type; you should consider changing it to a textbox.

+1


source


RTF is not the right way to go because it is not interpreted correctly by web browsers.
You should be using some markup language like Markdown used here.

0


source


I encrypt using base64_encode () and get using base64_decode (). Tabs, spaces and special characters are preserved.

$statement->execute(array(':cemail' => $c_email,
':ctel' => $c_tel, ':msg' => base64_encode($c_msg)));

$msg = $rd['texe;];
$msg = base64_decode($msg)

      

Works great for me

0


source







All Articles