Re: pop textarea field w/ text incl. quotes
| From: | Simon Garner | Date: | Thu, 22 Feb 2001 01:53:35 +0000 |
| Subject: | Re: pop textarea field w/ text incl. quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41094@lists.php.net to get a copy of this message | ||
From: "John Monfort" <monfort@kahuna.engineering.sdsu.edu>
>
>
> Is it necessary to include the 'http:' in the DB
> field?
>
> It would make your life a lot easier to drop it.
>
> You would then store the url values as
> www.mydomain.com
>
> Then, modify your code to add the 'HTTP' whenever it encounter a URL, or
> wherever you will create a link.
>
> This would eliminate the need to deal with special characters...
>
No it wouldn't, as the http:// is not the problem, the problem is the
HTML
markup. What Paul could do is have two DB fields, for the URL and the link
text, and then form the <A> tag at runtime instead of in the data. But this
maybe is not what he wants.
Eg
<?php
$linkurl = "http://www.blah.com";
$linktext = "Blah";
echo "<a href=\"$linkurl\">$linktext</a>";
?>
>
> On Wed, 21 Feb 2001, Paul Warner wrote:
>
> > Simon-
> >
> > Thanks for the tip...I trued using the htmlspecialchars() which allowed
the
> > remainder of the form to display properly, but left no value in the
> > textarea. Then I noticed a difference in the method I was using
compared to
> > yours - I'm still learning the ways of PHP so it will take me a while to
> > determine the significance of the syntax differences:
> >
> > Mine: <td width = "60%"><?php echo $linkurl .
> > '<br><textarea
> > value="htmlspecialchars($linkurl)"></textarea></td>\n' ?>
> >
> > Yours: <?php echo "<textarea>" . htmlspecialchars($link) .
> > "</textarea>"
?>
> >
> > I wanted a graphical representation of the present link displayed above
the
> > textarea and then attempted to use php's substitution to build the text
area
> > within the same string. I updated my code to be more like yours and
arrived
> > at:
> >
> > <?php echo $linkurl . '<br><form>'?><?php echo
> > "<textarea>" .
> > htmlspecialchars($linkurl) . "</textarea>\n"?>
> >
> > which seems to make the parser behave as I intended.
> >
> > Anyway...thanks!
> >
> > -- Paul
> >
> > ----- Original Message -----
> > From: "Simon Garner" <sgarner@expio.co.nz>
> > To: "Paul Warner" <pwarner@winners-circle.com>;
<php-general@lists.php.net>
> > Sent: Wednesday, February 21, 2001 8:19 PM
> > Subject: Re: [PHP] pop textarea field w/ text incl. quotes
> > >
> > > Don't worry about quotes - the problem is that you have HTML markup
inside
> > > your <textarea>. You just need to convert < and > to < and
> > > >,
> > > respectively, in your link text. The functions htmlspecialchars() or
> > > strip_tags() can do this for you.
> > >
> > > i.e.:
> > >
> > > <? echo "<textarea>" . htmlspecialchars($link) .
> > > "</textarea>" ?>
> > >
> > > When the form is submitted (and when it's viewed), those entities will
be
> > > converted back to their real characters automatically by the browser.
> > >
> >