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().

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.