PDA

View Full Version : help with html tags in php



wo1olf
July 16th, 2007, 02:57 PM
Basicaly i have 2 pages:
the first one add content into a db made with phpmyAdmin; the second one display that content from the data base.
In the first page i used htmlentities
like this:
$text = htmlentities(strip_tags($_POST['newTxt']));
mysql_query (...)
//update query
in the second one i used html_entity_decode
like this
$ result = mysql_query (...)
//get content query
while($row = mysql_fetch_array($result))
{
echo html_entity_decode($row['texte']);
}

The problem that i'm having is whenever there are html tags they are not interpreted but display in the html form
EX:if the text is <b>some text</b>
the display page show <b>some text</b> not some text
what do i have to change to get it work correctly ?

eirche
July 16th, 2007, 03:43 PM
you don't need htmlentities(strip_tags()) when storing in database. just do mysql_real_escape_string() before sending it to database. when you retrieve it, echo $row['newTxt']

wo1olf
July 16th, 2007, 05:45 PM
thnks but i still got the same problem may be it must be a syntax error,i'm going to post the whole code so if nay one see something wrong then le me know