Recovering HTML from a MySQL database

While working on a project with OpenCart a bug in one of the extensions managed to break some advanced HTML, which consequently became inaccessible. Here is an example of the raw content I had to work with when I exported the MySQL file.

<p>This paragraph contains some <em>HTML entities</em>. They can be confusing if you don't know HTML.</p>

The content in the MySQL file needed to be HTML, so I did a Google search for HTML entities conversion tools and came across www.htmlentities.net which helped me convert the text, so used in combination with find and replace to factor in new lines (the output HTML stored in a MySQL file can’t handle line breaks so inserts \n instead) and apostrophes I wanted to keep I came up with something like this:

<p>This paragraph contains some <em>HTML entities</em>. They can be confusing if you don&#39;t know HTML.</p>

This solves my problems of recovering the content and design I lost because the above HTML would render this in your web browser:

This paragraph contains some HTML entities. They can be confusing if you don't know HTML.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.