weetat wrote:
> Hi all,
> 
> I have the error below in my PHP version 4.3.2:
> 
> PHP Notice:  Array to string conversion in /data/html/library/config.php
> on line 45
> 
> If i have turned "on" the magic_quotes in php.ini, it is ok .
> Any ideas?
> 
> It cause by the code below:
> 
>   if (!get_magic_quotes_gpc()) {
>     if (isset($_POST)) {
>         foreach ($_POST as $key => $value) {
>             $_POST[$key] = trim(addslashes($value));
>         }
>     }
> 
>     if (isset($_GET)) {
>         foreach ($_GET as $key => $value) {
>             $_GET[$key] = trim(addslashes($value));
>         }
>     }
> }

// you might find something *like* this to be more flexible:

function arrayStripSlashes($v)
{
    if (is_array($v)) {
        foreach ($v as $key => $value) {
            $v[$key] = arrayStripSlashes($value);
        }
    } else if (is_scalar($v)) {
        $v = trim(addslashes($v));
    } else {
        $v = null;
    }

    return $v;
}

if (!get_magic_quotes_gpc()) {
        $_POST = arrayStripSlashes($_POST);
        $_GET  = arrayStripSlashes($_GET);
}


> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to