Questions tagged [magic-quotes-gpc]

`magic_quotes_gpc` is a PHP configuration setting enabling "magic quotes" (automatic escaping) for GET/POST/COOKIE variables.

When magic_quotes_gpc is enabled in PHP's configuration, PHP uses a method identical to addslashes() to automatically insert backslashes before certain problematic characters (\, ', ", and \0) in GET/POST/COOKIE values before they are passed to the script. The intent was to reduce the chance of their causing an error when interpolated directly into HTML or SQL, enabling PHP developers to write safer code without changing their habits.

Among their numerous drawbacks, though, is that if a script does properly escape data, assuming that magic quotes will be off, it will often break when this option is enabled; the resulting data will often have visible backslashes in it. In order to work both ways, a script needs to remove the added backslashes (using stripslashes()) if, and only if, magic quotes are enabled. Most problems these days have to do either with double-escaping caused by magic quotes, or with disabling the option on servers/hosts that have this misfeature enabled and do not allow configuration changes.

Magic quotes have been deprecated as of PHP 5.3, and removed entirely as of 5.4. Even in versions that still support them, their use is not recommended. The suggested course of action is instead to escape the data as needed, using a method appropriate for the data's intended destination.

More reading:

72 questions
0
votes
2 answers

Having an issue while installing Kayako Fusion

I am installing Kayako Fusion and get this error: Reason: Magic quotes is enabled in the php.ini configuration file. Please change magic_quotes_gpc to Off Unfortunately, Kayako cannot be installed. Either an error has occurred or your web server…
Zubir Ahmed
  • 49
  • 11
0
votes
1 answer

json_decode won't work without stripslashes (magic_quotes in WordPress)

On the client side, I'm working with array of JavaScript objects. On submit I need to send it to PHP with form and manipulate the data further on the server-side. So when building or changing an array of objects on the JavaScript side, I'm saving it…
Arman P.
  • 4,314
  • 2
  • 29
  • 47
0
votes
2 answers

PHP:magic_quotes_gpc can not start

I set the "magic_quotes_gpc" with the value "on" in php.ini,just like the following: ; Default Value: On ; Development Value: Off ; Production Value: Off ; http://php.net/magic-quotes-gpc magic_quotes_gpc = On but it seems doesn't work and I test…
ChainWay
  • 133
  • 1
  • 10
0
votes
1 answer

Quote and slash issue in PHP

Every time i try to update my textarea and inside the textarea I add a quote ", after i update i get 1 \, i update again i get 3 slashes \\\, again 5 slashes and so on. Tried adding in php ini the the 3 codes to disable the magic quotes but…
Adrian
  • 2,273
  • 4
  • 38
  • 78
0
votes
2 answers

how to turn off magic quotes in .htaccess file for joomla?

I started using Joomla 3 and now have problems and on searching i found that magic quotes need to be off for it to function correctly. I put these lines in the .htaccess file php_value magic_quotes 0 php_flag magic_quotes off php_value…
0
votes
0 answers

.htaccess - how to disable a magic_quotes when I don't have access to php.ini

I would like to disable a magic quotes on my page. I don't have access to php.ini... When I try add to my .htaccess this line: php_flag magic_quotes_gpc off I get: 500 Internal Server Error. In my index of errors, I found this: [Mon Nov 25 23:49:16…
user3022527
  • 2,107
  • 2
  • 14
  • 11
0
votes
1 answer

does Typo3 v4.5.30 auto escape strings?

I am trying to debug an issue (not my own code) with strings getting escaped and re-escaped repeatedly as the item is resaved. The code uses mysql_real_escape_string but even though magic quotes are turned off the post variables are already quoted…
0
votes
3 answers

php get_magic_quotes_gpc() how can I strip the inserted escape characters?

I am in the process of building my contact forms email address validation script. Having debugged it and run basic test's using valid email addresses which all passed I went on to test for invalid addresses. My first test was .ala.dom.com which is a…
Weedy101
  • 13
  • 1
  • 8
0
votes
1 answer

magic_quotes_gpc Does not show on php info page

I am watching tutorial videos to learn php and I am trying to setup my computer for working on php. Although the videos tell me how to shut off the magic_quotes_gpc, it does not show at all on php info page so, could you please help me with…
0
votes
2 answers

need to call mysql_real_escape_string() twice

I have some user-input data that is put into a MySQL database (version 5.5.8 according to phpMyAdmin) - I find that mysql_real_escape_string() in my example below must be called twice or no backslashes get added to a user input text such as "SHE'S A…
0
votes
1 answer

Why isn't disabling magic quotes in php.ini taking effect?

I disabled magic quotes at the end of my php.ini file in my root directory and there was no change. I am still getting backslashes in front of single quotes in $_POST entries. So I put a php.ini file in the same directory as the PHP file being run…
hal
  • 4,845
  • 7
  • 34
  • 57
0
votes
1 answer

Insert HTML code with php and magic quote on

I'm not an expert, so please don't laugh :) I'm writing a simple script to adjust some pieces of HTML, and I need to store them inside my db. I've magic quote on, I know that is deprecated but this is a local script. When I try to insert my html…
Roberto Pezzali
  • 2,484
  • 2
  • 27
  • 56
0
votes
2 answers

Joomla installation magic quotes issue

The latest Joomla 3.0 will need magic quotes to turn off in order to start the installation. As usual, i turn it off using php.ini created inside the sub folder where my joomla files are inside. in my phpinfo, magic_quotes_gpc is writing Off. but…
Bravo Net
  • 805
  • 5
  • 17
  • 30
0
votes
2 answers

Change 'magic_quotes_gpc = On' in web.config

How do I change the property magic_quotes_gpc = On to magic_quotes_gpc = Off in the web.config file? It's a server with IIS, and I can not edit the PHP.ini. I tried adding the below to the htaccess.txt file, but it doesn't work. php_flag…
Rui Martins
  • 3,337
  • 5
  • 35
  • 40
0
votes
2 answers

Replace % with - in url PHP

Ok i have one maybe stupid question On my website i have search options, that is input with GET metod, but when someone enter long seperated word like I AM SOMETIMES BLANK i got this in my…