[thelist] PHP htmlentities() ??

Bill Haenel bill at webmarketingworx.com
Thu Mar 28 20:34:01 CST 2002


I'm having a bit of trouble using PHP's htmlentities().

I'm using it like this...

htmlentities($text, ENT_QUOTES);

With ENT_QUOTES, it should translate both double and single quotes. But when
I try to send $text to MySQL, I get an error because $text contains single
quotes. The double quotes are translated as expected, but not the singles.

I've used this over and over again in a particular function that I've
applied in several sites. In fact, I've used it in the project I'm working
on right now, and it worked before.

Oddly enough, after having the trouble, I added this...

$text = ereg_replace("'", "'", $text);

...to the function, to emulate the part of htmlentities() that isn't
working. Even with that addition, single quotes are giving me trouble.
Perhaps the trouble is not with htmlentities()?

Wierd.

BH




More information about the thelist mailing list