--- whoisquilty <[EMAIL PROTECTED]> wrote:

> --- In php-list@yahoogroups.com, <[EMAIL PROTECTED]> wrote:
> >
> > ----- Original Message ----- 
> > From: "whoisquilty"
> > 
> > When I insert into my database from a form, there are slashes added before 
> > quotes. What do
> > I need to do to get rid of this?
> > 
> > ------------------------------------
> > 
> > foreach($_POST as $thisitem)
> >   {
> >   $_POST[$thisitem] = stripslashes($_POST[$thisitem]);
> >   }
> > 
> > or ...
> > foreach($_POST as $key=>$value)
> >   {
> >   $_POST[$key] = stripslashes($value);
> >   }
> > 
> > to make compatable with different server configs ...
> > if(get_magic_quotes_gpc())
> >   {
> >   foreach($_POST as $key=>$value)
> >     {
> >     $_POST[$key] = stripslashes($value);
> >     }
> >   }
> > 
> > same for alternate ...
> > if(get_magic_quotes_gpc())
> >   {
> >   foreach($_POST as $thisitem)
> >     {
> >     $_POST[$thisitem] = stripslashes($_POST[$thisitem]);
> >     }
> >   }
> > 
> > Hope this helps, Robert.
> >
> 
> Robert - Your solutions all insert the name of the submit button rather than
> pass the form data.
> 
> I've found that I have access to the ini file. But there is no entry for
> magic quotes. Is this 
> the best way to fix the problem? What do I need to add to do this?
> 
> Jeremy

Have you looked at the contents of the $_POST array?

printf("<pre>%s</pre>", print_r($_POST, true));

The variable name and button label (value) of the submit button is clearly one
of the pieces of data which is submitted.

None of the code he provided inserts into your database table.  If the wrong
variable and value is being inserted, that code must be examined.

This is the line in the php.ini file which controls Magic Quotes:

magic_quotes_gpc = On

If you do find you can change the file, you will also have to restart Apache
for it to be effective.

It is probably easier to put an ini_set() function call at the top of your
script if you want to turn off magic_quotes_gpc:

ini_set("magic_quotes_gpc", 0);

You may find that you don't have permission to change this parameter and it
could throw an error.

You can code around this.  It is not necessary to change this common
configuration value.

James

Reply via email to