Jump to content

[SOLVED] Why use "Stripslashes" and "Addslashes" Function


hanlonj

Recommended Posts

Guys,

 

Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...What advantage is this please?

 

Hanlonj

Link to comment
Share on other sites

addslashes is used to put back slashes in front of quotes so as to avoid syntax errors in sql queries in case the query contains some values that are taken from a text field.

 

Stripslashes would be used to remove the slashes in case we don't want them. For e.g. quite often magic_quotes_gpc is set to On in php.ini so that slashes are automatically added in from of quotes and there is no need to explicitly use addslashes. It is good to keep magic_quotes_gpc On so as to avoid SQL Injection attacks. But in this case if the values taken from the text field is to be displayed somewhere then the extra slash would appear in the output and hence stripslashes is used to remove the same.

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.