[PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Leila Lappin
Hello all,

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

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

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Leila Lappin
Hello all,

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

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

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Chris W. Parker
Leila Lappin mailto:[EMAIL PROTECTED]
on Thursday, June 09, 2005 7:46 AM said:

 == This is the rendering ===
 == (note the heart's apostrophe breaks IE and firefox) ===
 li
  a href=# onclick='document.form1.how.value=Pulmonary edema
 is a condition in which fluid accumulates in the lungs, usually
 because the heart's left ventricle does not pump adequately. In cases

Use htmlentities() instead.



Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Tom Rogers
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Tom Rogers
Hi,

TR What I do to overcome this is in PHP do:

TR $content = rawurlencode($content);

TR and in the html javascript:

TR unescape($content);


I didn't do that very well, your code would look something like:

li
  a href=# 
onclick='document.form1.how.value=unescape(?php 
rawurlencode($row['how'])?);
document.form1.factor.value=unescape(?php 
rawurlencode($row['factor']))?);
document.form1.submit();'?php htmlentities($row['factor'])?
  /a
/li




-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: Re[2]: [PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Leila Lappin
Hi,

I solved the problem by using htmlspecialchars and passing it ENT_QUOTES.
But I'll try your way as a more general way too.  Thanks


-Original Message-
From: Tom Rogers [mailto:[EMAIL PROTECTED]
Sent: Friday, June 10, 2005 8:36 PM
To: php-general@lists.php.net
Cc: Leila Lappin
Subject: Re[2]: [PHP] Problems escaping apostrophe, please help


Hi,

TR What I do to overcome this is in PHP do:

TR $content = rawurlencode($content);

TR and in the html javascript:

TR unescape($content);


I didn't do that very well, your code would look something like:

li
  a href=#
onclick='document.form1.how.value=unescape(?php
rawurlencode($row['how'])?);
document.form1.factor.value=unescape(?php
rawurlencode($row['factor']))?);
document.form1.submit();'?php htmlentities($row['factor'])?
  /a
/li




--
regards,
Tom

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php