I am wondering how to echo data stored in a database as rich text. I can put the data in the database, but it stores it as code. I want it to echo as formatted text using PHP. For example, if one of my users inputs the chemical formula CO2 with the 2 subscripted, it will be stored in the MySQL database as the code:
CO<sub>2</sub>
I don't want this code to be echoed. Instead I want the formatted text "CO2" to be echoed. Is this possible and if so how? I would like all the rich text markup to be echoed instead as actual formatted text rather than code.
echothe contents of the database should achieve exactly what you want. It sounds like you're running the value retrieved from the database through an escaping function, likehtmlentities()? However, you absolutely must ensure that any data you output without escaping is *clean*—if you store arbitrary user-provided data in that table, you could be vulnerable to XSS attacks.