Re: pop textarea field w/ text incl. quotes
| From: | Simon Garner | Date: | Thu, 22 Feb 2001 01:19:17 +0000 |
| Subject: | Re: pop textarea field w/ text incl. quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41087@lists.php.net to get a copy of this message | ||
From: "Paul Warner" <pwarner@winners-circle.com>
> I seem to be stuck on a very simple (to me) issue. I am trying to build a
> database of links for a site. A user inputs an HTML link into a text box
> which is stored in a SQL db. This works fine. I need to display this
data
> on pages, and retrieving it into the page displays fine as well. The
> problem arises when I need to provide a means to edit this link. Here's
> what I've got:
>
> Link as stored in db: <a
> href="http://winners-circle.com">Winners Circle
> Design Group</a>
> variants I've tried to store: <a
href=\"http://winners-circle.com\">Winners
> Circle Design Group</a>
> <a
> href=\\\"http://winners-circle.com\\\">Winners
> Circle Design Group</a>
> <a
> href='http://winners-circle.com'>Winners Circle
> Design Group</a>
>
> All result in the textarea box in the form being populated with (basicly
all
> the output to the end of the page): Winners Circle Design
> Group</a>"></form></td>\n </tr>
> <tr>
> <th width = "40%" align = "right">Created:</th>
> <td width = "60%">20010221195310</td>
> </tr>
> <tr>
> <th width = "40%" align = "right">Last Modified:</th>
> <td width = "60%">20010219104604</td>
> </tr>
> </table>
> </div>
> </body>
> </html>
>
> I'm sure that the answer is right in front of me, but my heads bleeding to
> badly from hitting the wall so many times, I can't see it!
>
> -- Paul
>
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.
Cheers
Simon Garner