Jump to content

text formating after mysql query


kooper

Recommended Posts

how can i keep my text formating after its queried from mysql
as an example

id if i posted this
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
hello

how are you
[/quote]

after its queried it becomes
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]hello how are you[/quote]

also, is there an easy way to block html in someones post?
i was thinking about useing bbcode
i tryed $comment = htmlspecialchars($_POST[comment]); but it doesnt seem to do very much
Link to comment
https://forums.phpfreaks.com/topic/10422-text-formating-after-mysql-query/
Share on other sites

Try the following script:
[code]
<html><head></head><body>
<p>You entered te following comment:</p>
<p>Without htmlspecialchars:</p>
<p>
<?php
echo $_POST['comment'];
?>
</p>
<p>With htmlspecialchars:</p>
<p>
<?php
echo htmlspecialchars($_POST['comment']);
?>
</p>
<p>Enter new comment:</p>
<form method="POST" action="<?php echo $PHP_SELF; ?>">
<input name="comment" type="text" />
<input name="submit" type="submit" value="submit" />
</form>
</body></html>
[/code]
And enter the following text as comment:
normal <b>bold</b> <i>italic</i>
Don't you see a difference with or without htmlspecialchars?

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.