neex1233 Posted July 5, 2009 Share Posted July 5, 2009 Hi everyone. I made a simple MySQL news script that works great, but I have one problem. The script escapes the text that they enter, and you know that it adds a slash (\) in front of it. I would like to remove that from the page, and I thought it be easy, and I could use str_replace, but if the user wants to display a slash (like he\she or something) it would remove that to. So, either they can't use slashes, they can't use characters that the mysql_real_escape_string escapes, or you could help me. Could yo help me? Thanks. Also, I thought after it gets in the database mysql would remove it, but I don't know if you can even do that. Link to comment https://forums.phpfreaks.com/topic/164854-how-to-remove-mysql-escape/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 5, 2009 Share Posted July 5, 2009 When you look directly in the database, the only \ characters should be ones that someone intentionally put in the data, i.e. your he\she example. If you have other \ characters and double \\ for the he\she example, it means your data was double escaped when it was put in. This is normally caused by magic_quotes_gpc and you actually need to use stripslashes() on the data first if magic_quotes_gpc is on to remove the escape characters before you use mysql_real_escape_string(). If the data is correct in the database but you are getting \ characters when you retrieve the data, that means magic_quotes_runtime is on. You can turn this setting off to prevent the problem (the first magic_quotes_gpc setting can only be turned off at the system level.) Link to comment https://forums.phpfreaks.com/topic/164854-how-to-remove-mysql-escape/#findComment-869282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.