I want to convert a string to HTML entities/special characters so that I can store it into MySQL database.
Example,
This is the way it is stored in MySQL database.
V3008-02, WS1 Drain Fitting 1” Straight w/Silencer
and when rendered on the browse it shows
V3008-02, WS1 Drain Fitting 1” Straight w/Silencer
My application built in PHP using phpBMS package. I want to convert the rendered text back to original text so that I can store back to database.
On the side note, which is the best way to store HTML tags in the database ?
Is it
A 'quote' is <b>bold</b>
or
A 'quote' is <b>bold</b>
Regards
https://www.php.net/manual/en/function.htmlspecialchars-decode.php
This is the answer to your problems.
I am not sure how you should store the HTML tags. Obviously you can’t store them in their original form, and it is bloated to use them with special entities. I recommend instead linking to a file that can be accessed that holds the HTML in it.
OK, you can store them as such, but you should use https://www.php.net/manual/en/function.addslashes.php this function, too.
I don’t think it’s efficient to store a large block of HTML in the field; I guess it depends on the size.