You are here: Re: [PHP] Problems escaping apostrophe, please help « PHP « IT news, forums, messages
Re: [PHP] Problems escaping apostrophe, please help

Posted by Tom Rogers on 09/28/87 11:18

Hi,

Friday, June 10, 2005, 12:05:48 AM, you wrote:
LL> Hello all,

LL> I hope this hasn’t been answered a zillion times already, I've tried
LL> everything I know and nothing has worked. The following is the PHP statement
LL> and the HTML rendering. The apostrophe is displayed as is and breaks the
LL> browser. May be I am wrong but I was under the impression that escaping
LL> special characters with one of the these, htmlspecialchars, htmlentities,
LL> and addslashes would replace them with encoded (hex?) value so they wont
LL> break the browser. But it hasn’t worked that way. I am using
LL> charset=iso-8859-1. This is my PHP:

LL> === This is the PHP ===
LL> <li>
LL> <a href="#"
LL> onclick='document.form1.how.value="<?=htmlentities($row['how'])?>";
LL> document.form1.factor.value="<?=addslashes($row['factor'])?>";document.form1
...submit();'>><?= addslashes($row['factor'])?>
LL> </a>
LL> </li>

LL> ====== This is the rendering =======
LL> ====== (note the heart's apostrophe breaks IE and firefox) ===
LL> <li>
LL> <a href="#" onclick='document.form1.how.value="Pulmonary edema is a
LL> condition in which fluid accumulates in the lungs, usually because the
LL> heart's left ventricle does not pump adequately. In cases of severe
LL> pulmonary edema, the symptoms will worsen and include A drop in blood
LL> pressure resulting in a thready pulse.";
LL> document.form1.factor.value="Pulmonary
LL> edema";document.form1.submit();'>Pulmonary edema
LL> </a>
LL> </li>

What I do to overcome this is in PHP do:

$content = rawurlencode($content);

and in the html javascript:

unescape("$content");

--
regards,
Tom

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация