You are here: Re: Weird: Slashes getting added « All PHP « IT news, forums, messages
Re: Weird: Slashes getting added

Posted by Erwin Moller on 02/28/06 16:24

Eric wrote:

> So, I've got this simple test PHP document (at the bottom of this
> message). It simply puts up a textarea and then submits the form to
> itself. The text of the textarea will be placed in 'body' of the $_POST
> array. If the $_POST['body'] variable is set, it outputs what 'body'
> contains and if not, it simply outputs 'No body var'.
>
> Ok...like, I said...pretty simple.
>
> Now, when I run this on my local machine, I enter:
> we'll
> in the textarea and when I submit the form, I get:
> we'll
>
>
> However, when I run this form on my webhost, I enter:
> we'll
> in the textarea and when I submit the form, I get:
> we\'ll
>
> Somehow a slash was added before the tick mark. Is this some
> configuration option? Does it have to do with how PHP is configured on
> the webhost? Does it have something to do with how Apache is configured
> on the webhost? Any idea how the slash got there?
>
> I'm just finding this rather odd and hoping to get an explanation.
>
> If it is easily explained, is the best way to get rid of the extra slash
> marks to call stripslashes()?
>
> If you want to see it in action on the webhost, just visit:
>
> http://www.ericgorr.net/slash
>
> <?PHP
> echo "<html><head><title>hello</title></head>";
> echo "<body bgcolor=#eeeeee>";
>
> if ( isset( $_POST['body'] ) )
> {
> echo $_POST['body'] . "<br>";
> }
> else
> {
> echo "No body var<br>";
> }
>
> echo "<form name=ContactPlayers method=post action=\"index.php\">";
> echo "<textarea cols=80 name=body rows=12></textarea>";
> echo "<br>";
> echo "<p><input type=submit name=submit value=Send>";
> echo "&nbsp;&nbsp;&nbsp;&nbsp;";
> echo "<input type=reset></p>";
> echo "</form>";
> echo "</body></html>";
> ?>


Hi

"magic_quotes_gpc" is turned on in the php.ini.

If you cannot change it, just add above EVERY script of yours:
ini_set("magic_quotes_gpc" , 0);

I took up the habbit of adding a file for every new project that contains a
few ini_sets, and if they fail, I let my app fail too.

It is the easiest way to overrule php.ini if you cannot or wish not to
change php.ini directly.
I think it is important to make such a file because you never know where
your application might end up. (Another ISP, or your current ISP changes
php.ini, etc.)

Remember that not all php.ini values can be overruled, so make sure you
check too if the ini_set() suceeded. (Like using ini_get() to check.)

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация