Matthew Matthew - 3 months ago 21
MySQL Question

Hyperlink on database varchar column

I have an insert into to the database and the text I insert have

<a href=""></a>
tags.

mysql_query("INSERT INTO `pm`(`message`) VALUES('You have been Invited to the team hello Click <a href="http://localhost:8080/competitive/accept.php">here</a> to accept.')");


and the result of the echo from the column is something like this:

You have been Invited to the team hello Click href="http://localhost:8080/competitive/accept.php">here to accept.


And I want it to looks like this:

You have been Invited to the team hello Click here/*this is an link*/ to accept.


How do I make it properly?

edit:

full code: http://jsfiddle.net/Mvpy8/ ps: dont run just see the code.

Answer

This should work as expected:

mysql_query("INSERT INTO `pm` (`message`) VALUES ('You have been Invited to the team ".$team_name." Click <a href=\"http://localhost:8080/competitive/accept.php\">here</a> to accept.')");
$result = mysql_query("SELECT `message` FROM `pm` LIMIT 1");
if($row = mysql_fetch_row($result)) {
    echo $row[0];
}

But you should use mysqli instead of mysql.

If this does not work, post the exact code you are encountering the problem with!