0

I have a question about a well known problem: the messages of my users contain hyperlinks to other area's of my website. I fetch data from the database to show the last message a user has posted on his profile. This works, but I can't see the hyperlinks. I just see them as plain text. How can I make these things hyperlinks as they should be?

I use this for example:

$lastpost = execute_scalar("SELECT message FROM messages where messages.user='$who' Order by date desc");

@Prasath Albert here you go:

    $message = preg_replace("'\look here: (.*)\)'Ui","(look here: <a href=\"haha.php?&q=\\1\">\\1</a>)",$message);
user1717526
  • 131
  • 1
  • 2
  • 14
  • put the code that generate the hyperlink for further investigation.. – Prasath Albert Oct 11 '12 at 09:14
  • How are the links presented in the database? As regular HTML ( – Coreus Oct 11 '12 at 09:19
  • How can you see this? Let me say this: people can click on a button, that fetches a javascript with inputfields. Their, they can link to an topic in my website. This is in the back-end with http:// but on the site, there is no http:// or whatsoever. It just says "spoon" or "football" for example and those are then links. @Prasath Albert: I have put the code as you asked – user1717526 Oct 11 '12 at 16:55

1 Answers1

0

use this links

Replace URLs in text with HTML links

http://zenverse.net/php-function-to-auto-convert-url-into-hyperlink/

Community
  • 1
  • 1
Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
  • Thanks for your answer Yogesh, but it did not work. It is still plain text. I used the code from your second link. Let me be clear: I have functions that produce internal hyperlinks without the WWw or HTTP:// before it. – user1717526 Oct 11 '12 at 16:51