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
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?
Link to comment
Share on other sites

thanks very much
i tryed adding it to the echo, which just rendered my bbcode useless.lol
so i added it to the mysql insert and with a little playing around with it, it worked perfect, thanks alot

now there just the formating thing to get sorted
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.