Every time I write the characters " and ' in any form of my drupal site they get a \ before them. That's very annoying because all my links are completely broken (in the href="url" I get href=\"url\").

Anyone experienced the same problems?

Comments

Dries’s picture

We can't help you unless you provide us enough information.

What Drupal version are you using? What PHP version are you using? Did you make any modifications? What value is magic_quotes_gpc set to?

pj@www.badopi.org’s picture

It seems that the .htaccess was not properly upload (at least uploading it another time solved the problem). The first reply was the correct :-)

For everyone's information my Drupal version was 4.2.0 rc2 (the one at the front page) and the problem happened to me with different versions of PHP (all 4.x).

magic_quotes_gpc was set like the Readme said :-)

gynther’s picture

I have the same problem, that's because my webhost doesn't allow me to use the, by Drupal, supplied .htaccess file. You have to make sure that the magic_quotes_* is set to the correct value, 0. You can check this with a simple info.php file that only contain the line php_info(). When viewing this page you'll get all information on the settings of your PHP server. Just look up the section containing magic_quotes.

At least this is what I think the problem originates from. Can anyone verify?

//Christian Gundersson
http://www.gundersson.com/drupal/

cczona’s picture

Some other people have been able to solve the magic quotes problem with this solution. Maybe it'll work for you too, though if your hosting co is really that restrictive it's not likely (they're being too paranoid--consider getting a different host).

To find out all the PHP config values (including magic quotes) your server is using, the full content of that file would be:

<?php phpinfo(); ?>

Make sure that the filename ends in ".php".

gynther’s picture

After reading your comment about them(my webhost) being too paranoid I decided to give the .htaccess file another go. So I commented everything out and started to try every line to see which were causing the problem. Turns out that magic_quotes works just fine, in fact everything works fine exept the Options -Indexes line. I even tried adding FollowSymLinks but that didn't help, I still get the error. Don't rightly know if that makes any bigger difference though, the site seems to work just fine without it.

//Christian Gundersson
http://www.gundersson.com/drupal/

pj@www.badopi.org’s picture

This was the problem :-)

Anonymous’s picture

phpinfo() tells me that magic_quotes_gpc is on

1. using the drupal .htaccess file (CVS from yesterday)
>
nothing happens

2.
ini_set("magic_quotes_gpc", 0); as first line in index.php (and info.php)
>
phpinfo() tells me that magic_quotes_gpc (local) is off now
but the quoting problem remains !!

seems that the provider ingnores .htaccess :(
any idea ?

Anonymous’s picture

a quick 'n' (very) dirty patch:
put these lines at top of index.php

while (list ($key, $val) = each ($_POST['edit'])) {
$_POST['edit']["$key"] = stripslashes ($val);
}

antisocial’s picture

didn't work for me. does it need to be at the very top of the code (immediately below the php open tag?)

Jose Reyero’s picture

Based on the previous one, but works also when there are arrays in the 'edit' array.

magic_stripslashes($_POST['edit']);

function magic_stripslashes(&$input){
if ($input){
while( list($key,$val) = each($input) ){
if( is_array($val)) {
magic_stripslashes($val);
} else {
$input[$key]=stripslashes($val);
}
}
}
}

You also have to comment out the following line in index.php

check_php_setting("magic_quotes_gpc", 0);