Jump to content

what are stripslashes


stuart7398

Recommended Posts

And for the use of it..say...when you have someone submit a comment and you use mysql_real_escape_string...so that there is no sql injection..when you want to display the comment say the comment was.."Hello, i'm matt" when you submit the comment, when it is inserted into the database it will be "Hello, i\'m matt" so when you display the comments you want you can use stripslashes() so that it appears as "Hello, i'm matt". Hope this helps you some. :)

Link to comment
Share on other sites

Basically emphasizing on what the previous poster said...

 

you will want to sanitize your mysql queries. When someone posts some data you're entering, you will usually want to add slashes to it just in case they try injecting it. So when you are displaying the data of what was inserted in to the query, you'll strip the slashes so it doesn't show things like

 

"Hi, I\'m a PHP coder."

 

Instead it'd show "Hi, I'm a PHP coder."

Link to comment
Share on other sites

When you escape data using slashes (addslashes, mysql_real_escape_string etc etc) and then store it within the database the slashes do not stay with the data, the slashes only escape bad characters so you can get the data into the database.

 

The only time you really need to use stripslashes is when you have escaped a string for whatever reason then would like to display it.

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.