Home > Archive > PHP Language > October 2006 > problem getting strip_tags to strip tags
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
problem getting strip_tags to strip tags
|
|
|
| I have a string coming from a tinytext field in MySQL like:
<font
color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
color="#000000"><strike>ssss</strike>sssss</font>
I get that field in a mysql query and reference it like:
echo strip_tags($row[4]);
It renders the same line without stripping any tags:
<font
color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
color="#000000"><strike>ssss</strike>sssss</font>
I tried casting it as a string just to make sure, no difference.
If I take that string, assign it manually to a variable and strip-tags, it
works:
$v = '<font
color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
color="#000000"><strike>ssss</strike>sssss</font>';
echo strip_tags;
Any ideas how I can get it to propoerly strip tags from the database?
| |
|
| what ifOn Sat, 7 Oct 2006 12:33:49 -0400, "Paul" <notreallyme@nowhere.invalid> wrote:
>I have a string coming from a tinytext field in MySQL like:
>
><font
>color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
>color="#000000"><strike>ssss</strike>sssss</font>
>
>I get that field in a mysql query and reference it like:
>
>echo strip_tags($row[4]);
>It renders the same line without stripping any tags:
><font
>color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
>color="#000000"><strike>ssss</strike>sssss</font>
>
>I tried casting it as a string just to make sure, no difference.
>
>If I take that string, assign it manually to a variable and strip-tags, it
>works:
>$v = '<font
>color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
>color="#000000"><strike>ssss</strike>sssss</font>';
>echo strip_tags;
>Any ideas how I can get it to propoerly strip tags from the database?
>
what if you do....
$value = settype($row[4] , "string" );
or
$value = html_entity_decode($row[4] );
echo strip_tags($row[4]);
make sure you are not saving string as htmlentities
| |
| Jeff North 2006-10-07, 7:00 pm |
| On Sat, 7 Oct 2006 12:33:49 -0400, in alt.php "Paul"
<notreallyme@nowhere.invalid>
<hBQVg.393$O65.0@bignews5.bellsouth.net> wrote:
>| I have a string coming from a tinytext field in MySQL like:
>|
>| <font
>| color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
>| color="#000000"><strike>ssss</strike>sssss</font>
>|
>| I get that field in a mysql query and reference it like:
>|
>| echo strip_tags($row[4]);
>| It renders the same line without stripping any tags:
>| <font
>| color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
>| color="#000000"><strike>ssss</strike>sssss</font>
>|
>| I tried casting it as a string just to make sure, no difference.
>|
>| If I take that string, assign it manually to a variable and strip-tags, it
>| works:
>| $v = '<font
>| color="#000000">s<strike><b>ss<u>s<i>sss</i></u></b></strike><u>ss</u>sss<strike>sssssss</strike></font><font
>| color="#000000"><strike>ssss</strike>sssss</font>';
>| echo strip_tags;
>| Any ideas how I can get it to propoerly strip tags from the database?
As a wild guess, try removing the double quotes
$row[4]=str_replace("\"","",$row[4]);
then apply the strip_tags.
echo strip_tags($row[4]);
I think, internally, the database string is already enclosed in double
quotes thus causing the function to stop at the first double quote it
finds.
As I said, a wild guess.
---------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
|
|
|
|
|