Jump to content

strange mysql escape string problem (slashes)


warpdesign

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.