"Greg Bryant" <bryantgHELLO@yahoo.com> schrieb im Newsbeitrag
news:Xns944F4714FD65bryantgHELLOyahoocom@199.45.49 .11...[color=blue]
> Pedro Graca <hexkid@hotpop.com> wrote in
> news:braiso$194j3$1@ID-203069.news.uni-berlin.de:
>[color=green]
> > Greg Bryant wrote:[color=darkred]
> >> Hi folks - I have a form that displays a value pulled from a database
> >> field.
> >>
> >><?php echo "<input type=text name='storename' value='$storename'>"; ?>
> >>
> >> I noticed that if $storename contains something like "Ma's Bakery",
> >> all that shows up in the field is "Ma". Do I really have to go
> >> through all my form fields and change them to
> >><?php echo "<input type=text name='storename'
> >>value='".$storename."'>"; ?>[/color]
> >
> > What hapenned when you tried that? :)
> >
> > try:
> >
> > <?php echo '... value="', htmlentities($storename, ENT_QUOTES), '">';
> > ?>
> >
> > Reference at
> >
http://www.php.net/htmlentities
> >
> >
> > Happy Coding :-)[/color]
>
> Thanks. Fortunately, I guess, I tried the second one first (escape
> double quotes around the value). Looking at it again, obviously the
> first one will have the same problem as the original :). Nice to know
> there's a real solution - htmlentities. Thanks!
>[/color]
With your "solution" you just switch problems - an entry as "She said:
"Let's go!", and went." will be cropped to "She said: ". You either have to
use htmlentities() or addslashes() with your content.
--
Markus