Re: Slash problem
| From: | Mike Eheler | Date: | Thu, 20 Dec 2001 00:25:28 +0000 |
| Subject: | Re: Slash problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-78272@lists.php.net to get a copy of this message | ||
This is done because magic_quotes_gpc is turned on. This makes it possible to just insert submitted data into a MySQL database, without preparing it first.
You can turn it off if you have access to the server config, or.. you can do this:
if (get_magic_quotes_gpc()) {
foreach ($HTTP_POST_VARS as $key => $value) {
// if you're into globals
$$key = stripslashes($value);
// otherwise -- not sure if this'll work or not
// if $HTTP_POST_VARS is read-only then it won't.
$HTTP_POST_VARS[$key] = stripslashes($value);
}
}
At the beginning of your scripts. If you do that, don't forget to *not* use global values.
Mike
Evansville Scene wrote:
I'm fairly new @ PHP, so forgive me if the answer is trivial ... In many cases, if I take in data from a form and the user uses an apostrophe, the data that is sent to me has a slash in it. For example: Jones\' Auto Repair Is there an easy fix? I'm not sure why this is occurring ... It\'s been quite a pain :) Adam