Jump to content

Recommended Posts

Hi! I'm  having a small issue with mysql_real_escape_string...The problem is i'm inserting some text into a DB and i'm using mysql_real_escape_string so that I can insert special character just as '  " ect...

 

The problem is when I output the text on the website i'm getting a \ before every special characters..... (ex : L\'artiste instead of l'artiste)

 

 

 

Is there any way to correct this??

 

 

p.s. Just ask if you need my code

 

Thanks!!!

magic_quotes_gpc is causing your form data to be automatically escaped (though not necessarily correctly for the character set being used in your database table.) Your use of mysql_real_escape_string() causes the data to be double-escaped. When the data is retrieved from the database it is still escaped because of the double-escaping.

 

If you can, you should turn off magic_quotes_gpc. It can be turned off using a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache Module.)

 

If you cannot turn it off, you should check if it is on in your code using get_magic_quotes_gpc() and the use stripslashes() on the data to remove the first set of escape characters only when get_magic_quotes_gpc() is TRUE. Then use mysql_real_escape_string() on the data. If you unconditionally use stripslashes(), that will prevent anyone from being able to enter a \ as data when magic_quotes_gpc is OFF.

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.