warpdesign Posted May 24, 2008 Share Posted May 24, 2008 I've created a simple page that allows me to update HTML that is stored in MySQL. It uses the Tiny MCE editor and basically it reads the field from SQL, places it into the Tiny MCE text field using htmlentities(), and when you hit submit it writes it back the SQL and I escape the value returned in the Tiny MCE field using mysql_real_escape_string(). Now on my test server it works perfectly, but on the live server it adds slashes to the text. So for example if I have a link in HTML like <a href="mylinkhere"> it gets turned into <a href=\"mylinkhere\"> I know I can add strip slashes to anywhere the text is read from the database but I'm wondering why this is happening only on the live server. I thought this was an issue with magic quotes being turned on on the live server but I put the following in my file and that did not fix the problem ini_set("magic_quotes_gpc", "0"); set_magic_quotes_runtime(0); I also added this to php.ini magic_quotes_runtime = off magic_quotes_gpc = off magic_quotes_sybase = off Link to comment https://forums.phpfreaks.com/topic/107117-strange-mysql-escape-string-problem-slashes/ Share on other sites More sharing options...
BlueSkyIS Posted May 24, 2008 Share Posted May 24, 2008 it is magic_quotes. i don't know why you can't turn it off. Link to comment https://forums.phpfreaks.com/topic/107117-strange-mysql-escape-string-problem-slashes/#findComment-549143 Share on other sites More sharing options...
mattal999 Posted May 24, 2008 Share Posted May 24, 2008 simple fix i always use: $content = $_POST['content']; //or whatever your text area is called $content = str_replace('/"', '"', $content); $content = str_replace("/'", "'", $content); and do the same for backslashes should fix it (its a problem with a form's post function and HTML clashing) Link to comment https://forums.phpfreaks.com/topic/107117-strange-mysql-escape-string-problem-slashes/#findComment-549145 Share on other sites More sharing options...
BlueSkyIS Posted May 24, 2008 Share Posted May 24, 2008 or.... $content = stripslashes($_POST['content']); Link to comment https://forums.phpfreaks.com/topic/107117-strange-mysql-escape-string-problem-slashes/#findComment-549147 Share on other sites More sharing options...
warpdesign Posted May 28, 2008 Author Share Posted May 28, 2008 Thanks, I'll give that a try. It's been driving me crazy! (I don't know why it won't let me just turn it off) Link to comment https://forums.phpfreaks.com/topic/107117-strange-mysql-escape-string-problem-slashes/#findComment-551795 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.