re:store html codes in text field (mysql)
am 07.01.2009 10:51:55 von muhsin
--------------050204000903020304080807
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
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=
heading 1
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...
Thanks alot for your time...
muhsin
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...
--
Extra details:
OSS:Gentoo Linux-2.6.25-r8
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash
Typo:40WPM
url:http://mambo-tech.net
--------------050204000903020304080807--
Re: re:store html codes in text field (mysql)
am 07.01.2009 22:53:47 von dmagick
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=
heading 1
>
> 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 ('heading 1
');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test;
+--------------------+
| html |
+--------------------+
| heading 1
|
+--------------------+
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/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: re:store html codes in text field (mysql)-SOLVED
am 08.01.2009 11:05:18 von muhsin
Chris wrote:
> 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=
heading 1
>>
>> 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 ('heading 1
');
> Query OK, 1 row affected (0.00 sec)
>
> mysql> select * from test;
> +--------------------+
> | html |
> +--------------------+
> | heading 1
|
> +--------------------+
> 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
>
Thanks for the replies....I did have htmlentities in one of my methods,
so html-entity-decode did the job...fixed now... :-)
--
Extra details:
OSS:Gentoo Linux-2.6.25-r8
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash
Typo:40WPM
url:http://mambo-tech.net
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php