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

 

 

 

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.