Re: Avoiding SQL injections: htmlentities() ?
| From: | Raj Shekhar | Date: | Sun, 27 Mar 2005 16:34:59 +0000 |
| Subject: | Re: Avoiding SQL injections: htmlentities() ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-211667@lists.php.net to get a copy of this message | ||
<tg-php@gryffyndevelopment.com> writes:
>
> So if I could broaden the question and ask, in general, what people
> recommend for pre-processing data before it goes into a SQL
> statement.. for security and for things like making sure
> singlequotes and other special characters are escaped properly?
>
>
> htmlentities()
> addslashes() (if magic quotes isn't turned on right?)
>
> What else?
>
Using some sort of database abstraction library (Pear::Db, Aoddb) also
helps. At least Adodb escapes the slashes in a SQL statement before
it is sent for execution. Using a library also provides a choke point
and you can add your own additional checks in the library without
letting the developers worry if they have done all the checks and
validations correctly.
--
Raj Shekhar Y! : Operations Engineer
MySQL DBA, programmer and slacker Y!IM : lunatech3007
home : http://rajshekhar.net blog : http://rajshekhar.net/blog/