title: How to remove htmlentities() values from the database?
body: <p>Long before I knew anything - not that I know much even now - I desgined a web app in php which inserted data in my mysql database after running the values through <code>htmlentities()</code>. I eventually came to my senses and removed this step and stuck it in the output rather than input and went on my merry way. </p>
  
  <p>However I've since had to revisit some of this old data and unfortunately I have an issue, when it's displayed on the screen I'm getting values displayed which are effectively htmlentitied twice. </p>
  
  <p>So,  is there a mysql or phpmyadmin way of changing all the older, affected rows back into their relevant characters or will I have to write a script to read each row, decode and update all 17 million rows in 12 tables?</p>
  
  <p>EDIT:</p>
  
  <p>Thanks for the help everyone, I wrote my own answer down below with some code in, it's not pretty but it worked on the test data earlier so barring someone pointing out a glaring error in my code while I'm in bed I'll be running it on a backup DB tomorrow and then on the live one if that works out alright. </p>