MySQL translating html tags

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

MySQL translating html tags

Post by atrichtch »

Hi all,

I have a common problem of trying to store HTML code in a MySQL database. Whenever I try to enter something that contains a special HTML character, like "<p>", it translates it into expressions like "<p>", which I don't want. What is the best way to avoid that?
Thanks.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: MySQL translating html tags

Post by McInfo »

Look for usage of the functions htmlspecialchars() or htmlentities() in your code.
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

Re: MySQL translating html tags

Post by atrichtch »

I didn't use any of those. I only used mysql_real_escape_string to add backslashes, but they didn't affect angle brackets.
Post Reply