patheticsam Posted March 24, 2010 Share Posted March 24, 2010 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!!! Link to comment https://forums.phpfreaks.com/topic/196378-little-problem-with-mysql_real_escape_string-please-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2010 Share Posted March 24, 2010 What does a phpinfo() statement show for both the magic_quotes_gpc and magic_quotes_runtime settings? Link to comment https://forums.phpfreaks.com/topic/196378-little-problem-with-mysql_real_escape_string-please-help/#findComment-1031086 Share on other sites More sharing options...
patheticsam Posted March 24, 2010 Author Share Posted March 24, 2010 GPC is On. Runtime is Off Link to comment https://forums.phpfreaks.com/topic/196378-little-problem-with-mysql_real_escape_string-please-help/#findComment-1031091 Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2010 Share Posted March 24, 2010 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. Link to comment https://forums.phpfreaks.com/topic/196378-little-problem-with-mysql_real_escape_string-please-help/#findComment-1031102 Share on other sites More sharing options...
patheticsam Posted March 24, 2010 Author Share Posted March 24, 2010 OK. Thanx, I will try to turn off GPC. I can edit php.ini file but how do I turn gpc off? (I'm a little bit new at this...sorry) Link to comment https://forums.phpfreaks.com/topic/196378-little-problem-with-mysql_real_escape_string-please-help/#findComment-1031132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.