[thelist] PHP htmlentities() ??
Hans Zaunere
zaunere at yahoo.com
Thu Mar 28 21:00:01 CST 2002
--- Bill Haenel <bill at webmarketingworx.com> wrote:
> 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.
Take a look at your magic_quotes settings in your PHP configuration.
Sometimes confusing things can occur with this.
> Oddly enough, after having the trouble, I added this...
>
> $text = ereg_replace("'", "'", $text);
Isn't that a no-op?
Try a test script to print the strings (before and after) out before
using them in MySQL. Also take a look at htmlspecialchars(), but
htmlentities() should work. Take a look at the magic quoting and
simply printing the strings to the screen. If they print correctly,
it's almost certainly a magic_quotes problem.
Hans Zaunere
New York PHP
http://nyphp.org
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - send holiday greetings for Easter, Passover
http://greetings.yahoo.com/
More information about the thelist
mailing list