Ashbow97 Posted June 5, 2011 Share Posted June 5, 2011 I'm not 100% sure if this is to do with PHP or MySQL mainly, but probably it includes both I'm trying to create a kind of guestbook/comment system on my website which is working pretty well so far, but I'm having one problem with \ when I'm inserting data into the MySQL database. Everytime I insert a word such as don't... it would come up in the database as don\'t. Then it also appears on the page that I've selected it for with don\'t which isn't very good. I know it's more than likely to make it so you can't break the code or something, but is there any way that when I select the data from the database, that it automatically gets rid of all the \s or something like that. Thanks, Ashbow97 Quote Link to comment https://forums.phpfreaks.com/topic/238462-annoying-s/ Share on other sites More sharing options...
harristweed Posted June 5, 2011 Share Posted June 5, 2011 http://es.php.net/manual/en/function.stripslashes.php Quote Link to comment https://forums.phpfreaks.com/topic/238462-annoying-s/#findComment-1225379 Share on other sites More sharing options...
Ashbow97 Posted June 5, 2011 Author Share Posted June 5, 2011 Thank you, that did the job Quote Link to comment https://forums.phpfreaks.com/topic/238462-annoying-s/#findComment-1225390 Share on other sites More sharing options...
Pikachu2000 Posted June 5, 2011 Share Posted June 5, 2011 If you're getting slashes actually inserted in the database, you aren't handling the data properly before inserting it. It's probably because magic_quotes_gpc is on, and you haven't checked for it before using mysql_real_escape_string(). if( get_magic_quotes_gpc() ) { $data = stripslashes($data); $data = mysql_real_eascape_string($data); } else { $data = mysql_real_eascape_string($data); } Quote Link to comment https://forums.phpfreaks.com/topic/238462-annoying-s/#findComment-1225443 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.