FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Backslash problem in input





imagefree
when i type a value say "HELLO\" in the input and post it to a script, and when i print the $_POST['value'] without any change, the printed value contains "HELLO\\".

I do not involve mysql, addslashes(), or any similar thing.
What is the problem?
sonam
This problem is comming out when the PHP directive magic_quotes_gpc is on (it's on by default).
http://www.php.net/stripslashes.

In that case you need to stripslashes your input.
Code:
echo stripslashes($_POST['value']);


Sonam
imagefree
can i stop it from working by using ini_set() ? How?
sonam
First be sure that magic quotes are enabled.
Code:
echo get_magic_quotes_gpc();


If this print out 1 then you can try this ini set command (I didn't test it):
Code:
ini_set('magic_quotes_gpc', false);


Sonam
imagefree
thanks sonam, i will try and let you know it there is still something wrong with the input.
imagefree
its not working. I am using this script and its still giving the value 1


Code:
<?php
ini_set('magic_quotes_gpc',0);
echo get_magic_quotes_gpc();
?>



also i used your recommended
Code:
ini_set('magic_quotes_gpc', false);
but it still doesnt work.
Peterssidan
you can get it to work using the the code on Example #2 at http://se2.php.net/manual/en/security.magicquotes.disabling.php
sonam
Quote:
In otherwords, use of ini_set() is not an option.


Peterssidan, thanks for link. Sorry, imagefree I make mistake. Sad

Sonam
Stubru Freak
imagefree wrote:
its not working. I am using this script and its still giving the value 1


Code:
<?php
ini_set('magic_quotes_gpc',0);
echo get_magic_quotes_gpc();
?>



also i used your recommended
Code:
ini_set('magic_quotes_gpc', false);
but it still doesnt work.


This of course can't possibly work as the $_POST data is already altered before your script gets called. Just my 2 cents.
Related topics
A PHP problem !
HTML + PHP problem
A php problem
Password problem
HTML Forms Problem
input - one line solution (basic)?
php include
problem with cgi perl script
phpNuke Register new users Problem Problem
Java bufferedReader problem
cash mod problem
Getting Hebrew User Input...
Problem with a script
how to create a pop-up input box? pls.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.