Question

So i am using a PHP-AIML program called program-e and it was going great, i knew it would be stable since it was finished a while ago, but it was for php 4.0.4 and now im on 5.0, so i dont know what to do.

the code of my foreach() functions is here:

// Turn this off in case people have it on.
set_magic_quotes_runtime(0);

// Can't turn off magic quotes gpc so just redo what it did if it is on.
if (get_magic_quotes_gpc()) {
    foreach($HTTP_GET_VARS as $k=>$v)
        $HTTP_GET_VARS[$k] = stripslashes($v);
    foreach($HTTP_POST_VARS as $k=>$v)
        $HTTP_POST_VARS[$k] = stripslashes($v);
    foreach($HTTP_COOKIE_VARS as $k=>$v)
        $HTTP_COOKIE_VARS[$k] = stripslashes($v);
}

and this is the error i get on the page:

Warning: Invalid argument supplied for foreach() in /home/content/80/8657080/html/e/src/admin/dbprefs.php on line 42

Warning: Invalid argument supplied for foreach() in /home/content/80/8657080/html/e/src/admin/dbprefs.php on line 44

Warning: Invalid argument supplied for foreach() in /home/content/80/8657080/html/e/src/admin/dbprefs.php on line 46

so how can i fix this problem.

Was it helpful?

Solution

From the PHP manual entry on Predefined Variablesdocs:

As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

This means that the (deprecated) $HTTP_GET_VARS, $HTTP_POST_VARS and $HTTP_COOKIE_VARS are probably turned off using the register_long_arrays directive.

You shouldn't be using these anyway as they've been deprecated for a really long time. Instead, use the $_GET, $_POST, and $_COOKIE superglobals.

Finally, not to be a downer, but I would personally stay away from anything optimized for a PHP version < 5.3 if at all possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top