Jump to content

Storing html code in a mysql field


Shadowing

Recommended Posts

Im having trouble figuring out how to update a field in mysql to everything that $message holds. So when I select it later and echo it it will display just as if I echo it with out putting it into mysql

 

$message = implode(", ",$b) . " from planet <a href='map.php?x=$attacker_x&y=$attacker_y&planet=
$attacker_address'>$attacker_planet</a> has joined your forces on planet " . $defender_planet_name . ".";

How do i set up a column to accept this.

 

I have my column set to

TEXT

with collation utf8_unicode_ci

 

Link to comment
https://forums.phpfreaks.com/topic/255927-storing-html-code-in-a-mysql-field/
Share on other sites

sorry thorpe i thought the code i posted was enough


$message = implode(", ",$b) . " from planet <a href='map.php?x=$attacker_x&y=$attacker_y
&planet=$attacker_address'>$attacker_planet</a>
has joined your forces on planet " . $defender_planet_name . ".";

$news1 = "INSERT INTO news SET time = '".($phptime)."', id = '".($_SESSION['user_id'])."', 
message = '".($message)."' , active = 0";		
$news = mysql_query($news1) or die(mysql_error());

 

just trying to insert into a column the variable $message holds . So when I select it later it returns with the html code. right now it just deny's the entry completely

lol the brackets half way worked. It got rid of the syntax error and i was able to echo it with a clickable link accept it puts the brackets around the link

 

The return was with Zoaghea being a clickable link

 

50 Jaffa from planet {Zoaghea} has joined your forces on planet Nashira.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.