htmlentities() and html_entity_decode(), with make_clickable
Posted: Mon Aug 01, 2005 1:43 am
I use this code to format entries into my forums
For some reason the make_clickable() function is converting the HTML it generates into htmlentities() (even though you can see in the code this shouldn't be.. (i think anyways))
Can someone tell me why?
It shoes up in the database as:
Edit: I promise I used tags.
.
Code: Select all
function make_clickable($text)
{
$ret = ' ' . $text;
$ret = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
$ret = substr($ret, 1);
return($ret);
}
// array of smilies here ($smilies)
// array of replacements for smilies here ($smiliesimg)
// array of specialtext here ($specialtext)
// array of specialtext replacements here ($replacement)
$entry2 = mysql_real_escape_string(nl2br(make_clickable(htmlentities($entry, ENT_QUOTES))));
$entry3 = str_replace($smilies, $smiliesimg, $entry2);
$entry4 = str_replace($specialtext, $replacement, $entry3);Can someone tell me why?
It shoes up in the database as:
Code: Select all
&lt;a href=\&quot;http://www.link.com\&quot; target=\&quot;_blank\&quot;&gt;http://www.link.com&lt;/a&gt;