strip-tags problem

strip-tags problem

am 10.01.2006 11:55:38 von William Young

Hallo, all

I have used this function.
$string = strip_tags($p1,'

');

The problem is that the title will be printed as well, but i dont allow the
title tag.

The intention is that people works from Word .doc domuments and saves the
files as html. then the html file can be inserted in the database.

How to i exclude the tag ?<br /> <br /> Thanks<br /> <br /> Danny</p> </article> <article> <h2>Re: strip-tags problem</h2><span>am 10.01.2006 12:34:51 von Stefan Rybacki</span> <p>-----BEGIN PGP SIGNED MESSAGE-----<br /> Hash: SHA1<br /> <br /> Danny wrote:<br /> > Hallo, all<br /> > <br /> > I have used this function.<br /> > $string = strip_tags($p1,'<i><b><u><br><p><font>');<br /> > <br /> > The problem is that the title will be printed as well, but i dont allow the<br /> > title tag.<br /> > <br /> > The intention is that people works from Word .doc domuments and saves the <br /> > files as html. then the html file can be inserted in the database.<br /> > <br /> > How to i exclude the <title> tag ?<br /> > <br /> <br /> Do you mean you want to remove the title tag as well as the text between the<br /> ending title tag?<br /> So you want "<title>title" to be "" instead of "title"?

Use a regular expression:

preg_replace("/[^<]*/","",$text);

but note if somewhere in the text is another title it will be
removed as well.

Regards
Stefan

> Thanks
>
> Danny
>
>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1rc2 (MingW32)

iD8DBQFDw5vbyeCLzp/JKjARAo2hAJ9l8JQ48YdUepfJ+luelk1xN+DYyACf c1kd
xdii1mYF0zVRI1pvdYeV49g=
=947o
-----END PGP SIGNATURE-----

Re: strip-tags problem

am 10.01.2006 13:18:28 von William Young

Thanks, but i still have problems,

When i escape the htm file, i cant update it into the database: Without the
preg_replace i get it into the database. Am i doing somthing wrong=

Danny

$par = mysql_real_escape_string(file_get_contents($p1));
$rep = preg_replace("/[^<]*/","",$par);

$query = "UPDATE prog set datum='$datum',titel='$titel',p1='$rep' " ;



> Danny wrote:
>> Hallo, all
>>
>> I have used this function.
>> $string = strip_tags($p1,'

');
>>
>> The problem is that the title will be printed as well, but i dont allow
>> the
>> title tag.
>>
>> The intention is that people works from Word .doc domuments and saves the
>> files as html. then the html file can be inserted in the database.
>>
>> How to i exclude the tag ?<br /> >><br /> ><br /> > Do you mean you want to remove the title tag as well as the text between <br /> > the<br /> > ending title tag?<br /> > So you want "<title>title" to be "" instead of "title"?
>
> Use a regular expression:
>
> preg_replace("/[^<]*/","",$text);
>
> but note if somewhere in the text is another title it will
> be
> removed as well.
>
> Regards
> Stefan
>
>> Thanks
>>
>> Danny
>>
>>
>>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1rc2 (MingW32)
>
> iD8DBQFDw5vbyeCLzp/JKjARAo2hAJ9l8JQ48YdUepfJ+luelk1xN+DYyACf c1kd
> xdii1mYF0zVRI1pvdYeV49g=
> =947o
> -----END PGP SIGNATURE-----

Re: strip-tags problem

am 10.01.2006 14:51:06 von Stefan Rybacki

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Danny wrote:
> Thanks, but i still have problems,
>
> When i escape the htm file, i cant update it into the database: Without the
> preg_replace i get it into the database. Am i doing somthing wrong=
>
> Danny
>
> $par = mysql_real_escape_string(file_get_contents($p1));
> $rep = preg_replace("/[^<]*/","",$par);

Try it the other way around. First the replacement then the escaping. You should
escape your string just before you do the query. (I also just saw that the
regexp was wrong, there was a backslash missing before the slash in .

$rep=file_get_contents($p1);
$rep = preg_replace("/[^<]*<\/title>/","",$rep);<br /> $rep = mysql_real_escape_string($rep);<br /> <br /> $query = "UPDATE prog set datum='$datum',titel='$titel',p1='$rep' " ;<br /> <br /> Regards<br /> Stefan<br /> <br /> >...<br /> -----BEGIN PGP SIGNATURE-----<br /> Version: GnuPG v1.4.1rc2 (MingW32)<br /> <br /> iD8DBQFDw7vKyeCLzp/JKjARAo4oAJ9Gj16O7pj3Qewx1RLmzly28i68ygCe PpDa<br /> p/0q4qb3mx6wvOfBirX4iH4=<br /> =+Rs9<br /> -----END PGP SIGNATURE-----</p> </article> <footer> <a href="/">Index</a> | <a href="/impressum.php">Impressum</a> | <a href="/datenschutz.php">Datenschutz</a> | <a href="https://www.xodox.de/">XODOX</a> </footer> </main> </body> </html>