Problem when reading html from database
I have the following stored in the database.
To view your new profile comment, go to your <a href='profile.php?id=1#comments'>profile</a>.
When selecting this in the message viewer,
profile.' /开发者_JAVA百科>
To view your new profile comment, go to your profile.
The profile.' />
actually breaks the script and ruins the design.
Is there any reason why this is happening that anyone is aware of?
Thanks
if you are using PHP, you can use htmlentities to convert the characters into HTML entities.
It's hardly recommended not to store any html in the database. Regarding of that, it must be a quotation issue, you should check that.
You need to encode the html to achieve something like escaping the '
as \'
. If you're using php you could use something like htmlspecialchars for example. http://uk.php.net/htmlspecialchars.
Or even better http://php.net/manual/en/function.mysql-real-escape-string.php.
精彩评论