I am desperate for some help. This following code is generating thousands of errors in my error log. I cannot find anything wrong with the code and everything "seems" to be working fine but the number of errors being generated by this script is absolutely ludicrous. Thanks in advance for any help...

The error:

[04-Sep-2009 16:57:44] PHP Parse error: syntax error, unexpected '=' in /home/finton/public_html/leagues/iscreentest.php(8) : eval()'d code on line 1

The code:

<?php
ini_set ('display_errors', 'Off');
ini_set ('php_value memory_limit', '200M');
ini_set('php_value register_globals','On');

while(list($key,$val) = each($_REQUEST)) {
        $test = "\$".$key." = '".$val."';";
        eval($test);
}
$browser = $_SERVER['HTTP_USER_AGENT'];
if($page == "iphone") {$leagueinfo[104] = 21; $iphone="YES";}
if(strstr(strtolower($browser),"iphone") || $page == "iphone" || strstr(strtolower($browser),"ipod")) {
        $leagueinfo[104] = 21;
        $iphone = "YES";
}

?>

    I would just replace that whole while() loop with:

    import_request_variables('gp');
    

    See [man]import_request_variables[/man] for more info.

      NogDog;10927033 wrote:

      I would just replace that whole while() loop with:

      import_request_variables('gp');
      

      See [man]import_request_variables[/man] for more info.

      Thank you. This makes sense to me. For my own benefit and for future reference so I don't make the same mistake again can you tell me why you think this error is occurring?

      Thanks

        My guess is that your $GET (or $POST or $COOKIE) array has $key names that contain characters that are illegal in variable names. A simple check would be to echo the $test string:

        while (list($key, $val) = each($_REQUEST)) {
            $test = "\$" . $key . " = '" . $val . "';";
            echo $test . '<br />';
            //eval($test);
        }

        For example, this code will produce an error message identical to yours:

        $_REQUEST = array('a-b' => 'c');
        while (list($key, $val) = each($_REQUEST)) {
            $test = "\$" . $key . " = '" . $val . "';";
            eval($test);
        }

        BTW, it's not necessary to escape the "$".

          Thanks all for your help. Changing the code as Installer suggested did the trick. The errors are now gone. I have not had a chance to delve deeper yet to find the root cause of the problem but I will take your advice NogDog and check out the variable names.

          Thanks for the rapid responses!

            Write a Reply...