Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I display ' and " inside input tags?

1 view
Skip to first unread message

Randell D.

unread,
Feb 11, 2003, 5:58:13 PM2/11/03
to

Folks,

I have a simple PHP database that I use to record and later re-display
articles for a small publication. Sometimes the headlines contain single
*and* double quotes... This is not a problem for me to display them in an
html output, but I have the option to re-edit the articles, meaning the
original form with original values is written back in... The problem is
though, I'm unsure as to how I can permit single and double quotes from
appearing inside a form text box, using something like the following, as an
example...

<input type=text name=headline size=30 maxlength=30 value=""They're not
there" he says">

I have considered using a backslash, but the backslash appears in the value
so if my idea is right, perhaps I''m implementing it wrong...

anybody got any ideas?

thanks
randelld


FlibberJibbet

unread,
Feb 11, 2003, 6:04:02 PM2/11/03
to
E.g.

" => &#34;
" => &quot;
' => &#39;

"Randell D." <you.can....@randelld.at.yahoo.com> wrote in message
news:9ef2a.239032$H7.83...@news2.calgary.shaw.ca...

FlibberJibbet

unread,
Feb 11, 2003, 6:11:00 PM2/11/03
to
E.g.

<input type="text"
name="headline"
value="&#34;They&#39;re not there&#34; he says">

Take a look at http://www.php.net/manual/en/function.html-entity-decode.php

"FlibberJibbet" <nu...@notarealaddress.com> wrote in message
news:Ejf2a.762$WR4....@newsfep4-glfd.server.ntli.net...

Markus Niederlechner

unread,
Feb 11, 2003, 6:20:47 PM2/11/03
to
Randell D. wrote:
[Escaping PHP output]

>
><input type=text name=headline size=30 maxlength=30 value=""They're not
> there" he says">
>
> I have considered using a backslash, but the backslash appears in the value
> so if my idea is right, perhaps I''m implementing it wrong...

You can use entities (e.g. &quot; for ") or character references (e.g.
&#34; for " and &#39; for ') to escape quotes in attribute values.

Jukka K. Korpela

unread,
Feb 11, 2003, 7:03:37 PM2/11/03
to
Markus Niederlechner <mnieder...@gmx.net> wrote:

> You can use entities (e.g. &quot; for ") or character references (e.g.
> &#34; for " and &#39; for ') to escape quotes in attribute values.

Yes, but the apostrophe need not be "escaped" when the attribute is enclosed
into quotation marks.

On the other hand, the question arises what _else_ gets written into the
attributes. If the data comes from database entries containing headlines,
there's really nothing to stop _any_ characters*) from getting into the
attribute values, unless some filtering is specifically programmed. I'm
pretty sure there's some general-purpose _function_ in PHP to handle such
issues.

*) such as the string &copy, which will be treated as copyright symbol by
browsers, or non-Ascii with potentially confusing effects.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Randell D.

unread,
Feb 11, 2003, 7:20:55 PM2/11/03
to

"Randell D." <you.can....@randelld.at.yahoo.com> wrote in message
news:9ef2a.239032$H7.83...@news2.calgary.shaw.ca...
>


Many thanks... I had been incorrectly playing around with urlencode and
urldecode but now see why I was wrong...

thanks for pointing me in the right direction...


0 new messages