UnknownPlayer Posted November 1, 2011 Share Posted November 1, 2011 Hi, i insert in db with mysql_real_escape_string() function, but when i read i use this: - htmlentities(stripslashes($value), ENT_QUOTES, "UTF-8") - for all fields but no textarea - stripslashes($value) - for textarea, becouse when insert that textare, its tinymce, and have html tags Is this right way ? Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/ Share on other sites More sharing options...
Pikachu2000 Posted November 1, 2011 Share Posted November 1, 2011 There should be no need to use stripslashes() on data that was properly escaped when it was inserted. Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/#findComment-1284008 Share on other sites More sharing options...
UnknownPlayer Posted November 1, 2011 Author Share Posted November 1, 2011 I removed tinymce, just left: - when insert mysql_real_escape_string() - when echo htmlentities but when there is char " it show like "\ how can i fix that? Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/#findComment-1284025 Share on other sites More sharing options...
Pikachu2000 Posted November 1, 2011 Share Posted November 1, 2011 If data is retrieved from the database with slashes in it, either it wasn't properly escaped when it was inserted, or something is adding the slashes after retrieval. magic_quotes_gpc or magic_quotes_runtime may be on, or you have something applying addslashes() to your data. If you view the data in phpMyAdmin or the MySQL command line client, are the slashes there or not? Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/#findComment-1284027 Share on other sites More sharing options...
UnknownPlayer Posted November 1, 2011 Author Share Posted November 1, 2011 In db is like: \" but on my localhost server this thing works fine, but on webserver it doesnt, it shows \". I tested, i put echo mysql_real_escape_string($_POST['opis']); on page that insert data, and it echo \r\n\\\" What is problem ? Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/#findComment-1284033 Share on other sites More sharing options...
Pikachu2000 Posted November 1, 2011 Share Posted November 1, 2011 magic_quotes_gpc is on, so the data is being double escaped. You'll want to turn off magic_quotes_gpc in your php.ini file, and restart Apache. You may need to check with the host to see how to do that. Then you'll need to run an UPDATE query to get rid of the unnecessary slashes added to the data, or import it from a "clean" source. Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/#findComment-1284036 Share on other sites More sharing options...
UnknownPlayer Posted November 1, 2011 Author Share Posted November 1, 2011 Thanks i did that, adn restarted services in phpinfo is now off, and is works, thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/250238-help-with-echo-and-insert-in-db/#findComment-1284040 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.