Quite some time ago I wrote a RSS parser. It worked fine until now, when I turned my error and notice reporting on. Currently I keep getting quite a lot of notices that tell me that something is wrong in the function. I tried solving this problem on my own, but I had no success. Could You please help me with this error?
The error:
Notice: Undefined index: RSS in C:\xampp\htdocs\Dropbox\RECtus\System\sysFiles\libarys\myRSSParser.lib(103) : eval()'d code on line 1
Notice: Undefined index: LINK in C:\xampp\htdocs\Dropbox\RECtus\System\sysFiles\libarys\myRSSParser.lib(103) : eval()'d code on line 1
The script:
function parseData($parser, $data) {
if(!trim($data)) return;
$RSS = '';
$evalcode = "\$this->output";
foreach($this->tags as $tag) {
if(is_array($tag)) {
list($tagname, $indexes) = each($tag);
$evalcode .= "[\"$tagname\"]";
if(!isset(${$tagname})) ${$tagname} = '';
if(${$tagname}) $evalcode .= "[" . (${$tagname} - 1) . "]";
if($indexes) extract($indexes);
} else {
if(preg_match("/^([A-Z]+):([A-Z]+)$/", $tag, $matches)) {
$evalcode .= "[\"$matches[1]\"][\"$matches[2]\"]";
} else {
$evalcode .= "[\"$tag\"]";
}
}
}
eval("$evalcode = $evalcode . '" . addslashes($data) . "';");
}
Line 103 is the eval() line.
$evalcodejust before theeval(). Also, one of the two$evalcodestrings in theeval()call should probably be escaped, e.g.eval("\$evalcode = $evalcode . '" ...eval()in the first place. There are several XML parsers and a few RSS-specific XML parsers available for PHP ... The best way to really solve your problem is not usingeval(), it's notoriously hard to debug and prone to errors.echoon eval argument to see whateval()tries to evaluate?