Re: forms addslashes ?
| From: | Lars Torben Wilson | Date: | Thu, 19 Jun 2003 07:26:50 +0000 |
| Subject: | Re: forms addslashes ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152118@lists.php.net to get a copy of this message | ||
On Thu, 2003-06-19 at 05:27, Mukta Telang wrote:
> Hi,
> I want to add slashes to a string, if it contains quotation marks and
> which is received as input from a form, so that I can enter it to a
> database.
> What I am doing is as follows:
>
> echo "<input type=\"text\" name=\"title\">;
> $title=addslashes($title);
>
> But the string that gets added has a lot of slashes!
> How should this be done?
> Mukta
Do you mean that there are two slashes everywhere there should be one,
or that they are inserted where you do not expect them?
It's slashes doubling up on you, you may have magic_quotes_gpc enabled
in php.ini. magic_quotes_gpc is explained here:
http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc
You can check whether it's turned on with:
http://www.php.net/get_magic_quotes_gpc
http://www.php.net/get_magic_quotes_runtime
So if that's the case, you could either disable magic_quotes in
php.ini, or else test whether it's turned on and then decide whether to
call addslashes().
Torben
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----