UnknownPlayer Posted November 30, 2011 Share Posted November 30, 2011 Hi, i use mysql_real_escape_string() function when insert in db, but when echo i use htmlentities($var, ENT_QUOTES, "UTF-8") Now problem is '\ in that text. In db it write text with single quote with \, example That\'s wrong, and when echo it show just the same like in db.. How can i fix this ? Quote Link to comment https://forums.phpfreaks.com/topic/252146-problem/ Share on other sites More sharing options...
php_king Posted November 30, 2011 Share Posted November 30, 2011 After searching and experimenting, I believe that what you need in order for it to display correctly when you call it from the database is the function: stripslashes() Quote Link to comment https://forums.phpfreaks.com/topic/252146-problem/#findComment-1292741 Share on other sites More sharing options...
requinix Posted November 30, 2011 Share Posted November 30, 2011 Rather than deal with bad data, make sure the data is good instead. You probably have the magic_quotes php.ini setting enabled. Disable that and restart the server. Quote Link to comment https://forums.phpfreaks.com/topic/252146-problem/#findComment-1292743 Share on other sites More sharing options...
UnknownPlayer Posted December 1, 2011 Author Share Posted December 1, 2011 magic_quotes need to be disabled ? I use stripslashes(), is that correct way too ? Quote Link to comment https://forums.phpfreaks.com/topic/252146-problem/#findComment-1292952 Share on other sites More sharing options...
requinix Posted December 1, 2011 Share Posted December 1, 2011 stripslashes() is the workaround to the magic_quotes problem. Solve the problem itself by disabling that setting. Quote Link to comment https://forums.phpfreaks.com/topic/252146-problem/#findComment-1293187 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.