I want to create a string in PHP, and store that string in MySql database. But when i need to read that string from database and print in HTML format, this string must be well formatted and should be valid HTML code.
Eg. Links should be working, heading tags, class, css all my work when this string is echoed.
$var= mysql_real_escape_string($var);
Use this!
Well...
PHP is bassically a language that creates source of web page.
Everything that your PHP code will echo/print will be sent to browser.
If text produced with PHP will be HTML code - it will work as HTML code in browser.
Try this:
<?php
echo "<a href='http://stackoverflow.com'>this is valid link</a>";
?>
It doesn't matter where your text comes from (database, variable, function). If you echo it - it will go to browser.
Maybe watch some these video tutorials about PHP and see how it works: