RE: [PHP] addslashes() and stripslashes()
| From: | Matt Schroebel | Date: | Wed, 14 Aug 2002 17:51:05 +0000 |
| Subject: | RE: [PHP] addslashes() and stripslashes() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-112562@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: ed [mailto:coo_t2@yahoo.com]
> Sent: Wednesday, August 14, 2002 1:48 PM
> To: php-general@lists.php.net
> Subject: [PHP] addslashes() and stripslashes()
>
>
> Is it a good idea to always use addslashes() on a
> value gathered from a text field or textarea?
Yes, always.
> If you use addslashes() to "INSERT" the stuff into a
> db, should you always use stripslashes() when you
> "SELECT" it from the database?
No, the slashes are there for so the SQL engine can separate the data from the sql statement.
What's inserted or updates is the pre-addslashes value. Generally, if you don't
addslashes() the sql statement won't execute.