-- Jan Schnackenberg <[email protected]> wrote
(on Tuesday, 23 December 2008, 10:30 AM -0800):
> I did the QuickStart tutorial and that seemed to work more or less straight
> forward (except for the fact that I cannot use <? as PHP-open-tag and I find
> it irritating that this is used here while the coding-standard for ZF says
> to always use <?php, but... anyway...)

Our messaging has always been to use <?php for PHP files, <? with view
scripts.

> My "problem" is, that the text, entered into the "comment" area is written
> to the database with quotes. So if I enter
> 
> test'"\
> 
> in that field I see the text
> 
> test \'\"\\
> 
> in the "guestbook" and also in the database-file (less is my friend).
> 
> I cannot find the place where this quoting happens, though. After about 3
> hours digging through the code and getting my brain into a knot I've given
> up.
> 
> How do I stop this "writing-quoted-strings-to-database"? I understand that
> quoting has to be done in a way, but what happens here seems to be some kind
> of "double-quoting" as the quotes appear in the database, too?

Most likely, you've got magic_quotes_gpc enabled on your server. You can
verify this by checking it in a script:

    <?php
    if (get_magic_quotes_gpc()) {
        echo "Magic quotes enabled";
    }

If they are, you have two options:

  * Preferred: disable them in your php.ini file. Look for the
    "magic_quotes_gpc" directive.
  * If you cannot do the above, then you need to add some handling in
    your scripts. Try adding this into your bootstrap:

        function stripMagicQuotes(&$value)
        {
            $value = (is_array($value))
                   ? array_map('stripMagicQuotes', $value)
                   : stripslashes($value);
            return $value;
        }
        stripMagicQuotes($_GET);
        stripMagicQuotes($_POST);
        stripMagicQuotes($_COOKIE);

-- 
Matthew Weier O'Phinney
Software Architect       | [email protected]
Zend Framework           | http://framework.zend.com/

Reply via email to