eval() is inefficient, in that each invocation of it requires the launching of a separate PHP process. It's sort of like running a separate mini PHP script (not necessarily a big deal on modern servers when used in reasonable amounts and when the site is not running near max capacity).
It's also a potential security risk. For instance, imagine through either an honest mistake or via a malicious hacking that the database field being used had a string inserted into it which, when eval()'d, could do something you really wouldn't like done. You likely would not know it until after the fact and after the damage was done.
I might consider using 3 fields: variable_name, operator, and value. Then you could use something like the following to do the comparison:
$varname = $row['var_name'];
$operator = $row['operator'];
$value = $row['value'];
switch($operator)
{
case '==':
$result = (${$varname} == $value);
break;
case '!=':
$result = (${$varname} == $value);
break;
// repeat for each valid operator..., then...
default:
// die(), or user_error(), or whatever you want when invalid/empty operator
}
if($result) {
// whatever when comparison is true....
}
Not the most elegant code, perhaps, but it is much safer, IMO.