Page 1 of 1

Problems with eval

Posted: Sat Feb 21, 2004 9:27 pm
by oohkumar
I'm trying to get Vbulletin code to work properly.

I'm having a problem with the eval function in the admin/options.php file in vbulletin.

eval ("echo \"$setting[optioncode]\";");

produces this error:

"Parse error: parse error, expecting `','' or `';'' in /usr/local/apache/htdocs/vbulletin/admin/options.php(72) : eval()'d code on line 2"

If I change the inner quote marks to singles:

eval ("echo '$setting[optioncode]';");

then I lose the error message but some of the source code html does not print correctly, for instance it prints out some php code where instead there should be html such as:

<select name=\"setting[$setting[settingid]]\">

Any idea on how to get the eval function working properly so that I no longer get error messages and it prints out html correctly.

Thanks,

oohkumar

Posted: Sat Feb 21, 2004 10:18 pm
by Albright
So what do you want echo'd? "$setting[optioncode]", or the value of $setting['optioncode'] ?

If it's the latter, try this. Note how the key to $setting[] is set apart by quotes.

eval ("echo '".$setting['optioncode']."';");

But, call me silly, but why is eval() being used in this way? Why not just

echo $setting['optioncode'];

?