Jump to content

help on preventing injections


ohdang888

Recommended Posts

Here's the short of it:

 

If the data came from post or get and Magic Quotes is on, call stripslashes() on it first.

 

Then you call mysql_real_escape_string() on it before inserting it into the database.

 

You do not call functions like striptags() or htmlentities() on data going into the database.  Rather you reserve that for when you are about to display that data to a browser.

 

Any time you put data into your database, you want it intact as much as possible.  Which means the only things you should do to it is stripslashes() (and only if magic quotes is on) followed by mysql_real_escape_string().

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.