Re: re:store html codes in text field (mysql)
| From: | Chris | Date: | Wed, 07 Jan 2009 21:53:47 +0000 |
| Subject: | Re: re:store html codes in text field (mysql) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45869@lists.php.net to get a copy of this message | ||
mrfroasty wrote:
Sorry if this has been asked before but I cant seem to find anything useful via google...... I have a text fields which stores my textarea input from a user, my design is meant to allow user to submit html codes...but mysql seem to replace all html tags with something else... Example: $title="some text"; $html_code=<h1>heading 1</h1> INSERT INTO $db_table VALUES(null,'$title','$html_code')"; Result in my dB: 1]some text 2]<h1>heading <h1> How can I solve this problem of mysql replacing the html tags.....?This is probably something familiar to webdev, but I am kind of a noob in web programming...mysql is 100% not doing it. If you did that manually in mysql, you would get the right results. mysql> create table test (html text); Query OK, 0 rows affected (0.01 sec) mysql> insert into test(html) values ('<h1>heading 1</h1>'); Query OK, 1 row affected (0.00 sec) mysql> select * from test; +--------------------+
| html |+--------------------+ | <h1>heading 1</h1> | +--------------------+ 1 row in set (0.00 sec) You have a htmlspecialchars or htmlentities call between $html_code being set and where you're doing the insert.
N:B The only way I can think of is replacing them after pulling them out of the dB, but I am not sure if this is the way to go...See http://au.php.net/manual/en/function.html-entity-decode.php -- Postgresql & php tutorials http://www.designmagick.com/