Re: quotes in text.
| From: | Justin Patrin | Date: | Fri, 16 Jul 2004 20:05:39 +0000 |
| Subject: | Re: quotes in text. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190748@lists.php.net to get a copy of this message | ||
On Fri, 16 Jul 2004 11:58:55 -0500 (EST), Ed Curtis <ed@homes2see.com> wrote:
>
>
>
> On Fri, 16 Jul 2004, John W. Holmes wrote:
>
> > Let's say you have $_POST['text'] from the user.
> >
> > To display the value back to the user with magic_quotes_enabled, you'd
> > do this:
> >
> > echo htmlentities(stripslashes($_POST['text']));
> >
> > To put the value into a hidden form element, you'd do this:
> >
> > <input type="hidden" name="text"
> > value="<?=htmlentities(stripslashes($_POST['text']))?>">
> >
> > Now, $_POST['text'] will come out correctly on Page 3. Since you seem to
> > have magic_quotes_gpc enabled, you can put the value directly into your
> > query.
>
> Actually when I tried the above example nothing was entered into the
> database. This worked.. htmlentities($_POST['text']).
>
This is why he said: "Since you seem to have magic_quotes_gpc enabled,
you can put the value directly into your query."
You shouldn't use htmlentities when putting it into the DB. Use it
when displaying the text.
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--