Jump to content

Make links in text


davidb52

Recommended Posts

hello this is my code:$query2 = mysql_query("SELECT blog FROM users WHERE id='" . mysql_real_escape_string( $ido ) . "'");while($row2 = mysql_fetch_array($query2)){$data[] = $row2;foreach ($data as $row2);$blog = $row2['blog'];echo htmlentities($blog);}I use htmlentities so people can't use <b >bold< / B> tags.But how I grab links and make them clickable.like:this is my holiday,first day we started here google.comNice picture's huh?but what i want:this is my holiday,first day whe started here google.comNice picture's huh?How can I make something like that?

Link to comment
Share on other sites

You might want to use strip_tags instead of htmlentities, and tell it to keep <a> tags.http://www.php.net/manual/en/function.strip-tags.php
yeah I now,but I mean dumb people can have text like:(what user can put in, this is what in database)this is a test look here ttp://google.com (I notice if i put htt(p) it also makes automatic a link, thats what I want but that it also works with al these example's)this is a test look here www.google.comthis is a test look here google.comand makes it clickable(what the site echo)this is a test look here http://google.comthis is a test look here www.google.comthis is a test look here google.comsorry for bad english (I'm from the Netherlands)
Link to comment
Share on other sites

really thank you!i'm using:

$message = preg_replace("  #((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie",  "'<a href=\"$1\" target=\"_blank\">$3</a>$4'",  htmlentities($message));echo $message;

<b >BOLD etc doesn't work exactly what I want</ b> and links with (h)ttp://google.com become http://google.comthis is good now,not really necessary but is there a script for just google.com www.google.com?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...