Jump to content

Recommended Posts

I'm getting 3 slashes when I use mysql_real_escape_string and then when I use stripslashes nothing happens. I still have 3 slashes.

 

I turned off mysql_real... And am still getting a preceding slash, leading me to believe it's a server/php setting... However, stripslashes still does nothing so my sentences all look like this to users:

 

That\'s a great Joe's BBQ sandwhich!

 

Any advice is appreciated!

I want it to be like this when outputted:

 

That's a great Joe's BBQ sandwhich!

 

No slashes (of course, unless someone put them in there).

 

I assume I can just make my own function

str_replace("\'", "'", $string); but I still don't get why stripslashes isn't working... I hate to make a workaround when I could potentially fix the problem at its root. I did some research and found magic_quotes_sybase being on will disable stripslashes normal function and make it replace double stacked apostrophes ''  but sybase is OFF.

It would help if you described the flow of data and at what point it has the excess slashes.

 

However, the problem is likely due to magic_quotes_gpc (escapes GET, POST, and COOKIE data, even if you don't want them to be) and magic_quotes_runtime (escapes data retrieved from databases and files, even if you don't want them to be.)

 

If your data is escaped correctly, a single time by mysql_real_escape_string(), the actual \ should not be present in your table (unless someone had a \ as part of the data.) This will help you pin down if the problem is occurring when the data is being input or when it is being retrieved.

 

If you cannot turn off the magic_quotes_gpc setting, you would then need to use stripslashes() if magic_quotes_gpc is ON to remove the escape characters before you use mysql_real_escape_string(). You should not unconditionally use stripslashes() because that would prevent any actual \ in the data when magic_quotes_gpc is OFF.

The excess slashes appear to have been due to my use of mysql_real_escape_string. I removed its usage until the next PHP upgrade.

 

stripslashes wasn't working because I was using it in the wrong place (on the right variable, but a similar looking location in the file).

 

Thank you for your help!

 

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.