Now I got a query that contains HTML code and when I select it in php it makes the code,
$query = mysql_query("SELECT * FROM `table`")or die(mysql_error());
while($arr = mysql_fetch_array($query)){
$num = mysql_num_rows($query);
$code = $arr ['code'];
echo $code;
}
and in that query there is this code <a href="http://google.com">Click Here</a>
when it echo it shows me Click Here, But I want it to sows me the code.
So how can I do that in PHP.
Thanks
Klaus
Use htmlspecialchars()
to prevent HTML elements from being interpreted by the browser.
$query = mysql_query("SELECT * FROM `table`")or die(mysql_error());
while($arr = mysql_fetch_array($query)){
$num = mysql_num_rows($query);
$code = $arr ['code'];
echo htmlspecialchars($code);
}
Just encode the output with htmlspecialchars
$query = mysql_query("SELECT * FROM `table`")or die(mysql_error());
while($arr = mysql_fetch_array($query)){
$num = mysql_num_rows($query);
$code = $arr ['code'];
echo htmlspecialchars($code);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With