Jump to content

little problem with mysql_real_escape_string please help!


patheticsam

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.

Archived

This topic is now archived and is closed to further replies.

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