ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Core Functions Error Code

June 21, 2007 2:02pm

Subscribe [2]
  • #1 / Jun 21, 2007 2:02pm

    mpace

    20 posts

    Well, this is pretty beyond me 😛 I figured I’d throw this error up here in hopes someone has a general idea of what it means.

    I am trying the simplepie rss parser within in expressionengine, and i get this error. I am not a php programmer so this is a bit advanced for me.

    “Warning: Invalid argument supplied for foreach() in /home/usr/public_html/site/system/core/core.functions.php(629) : eval()‘d code on line 12”

    The chunk of code that is on line 629 is the following.. (well, the “return eval” line is 629)

    function evaluate($str)
        {    
            return eval('?>'.$str.'<?php ')
            
            // ?><?php // BBEdit syntax coloring bug fix
        }

    Does anyone know what that means? Not necessesarily looking for a way around it, I don’t want to break anything, but if it’s simple I might try it out.

    I’m currently debating between SimplePie and the packaged magpie plugin. There are pros and cons for each, but just want to see if I can get SimplePie working at all.

    Oh, and this error is happening when I try to spit out the results (4 feed sources), which is in a php foreach loop.

    Thanks

  • #2 / Jun 21, 2007 2:32pm

    Derek Jones

    7561 posts

    PHP in templates is evaluated with the function you have copied above.  The eval’d code’s line 12 is the problem, which would mean the code in the script you are using in your template.

  • #3 / Jun 21, 2007 2:41pm

    mpace

    20 posts

    PHP in templates is evaluated with the function you have copied above.  The eval’d code’s line 12 is the problem, which would mean the code in the script you are using in your template.

    hmm.. the only code i have in the actual template is a foreach loop.

    <?php
        // Let's loop through the array of feeds we created earlier.
        foreach($feeds as $feed):
        ?>
    
    <div class="feed">

    Line 12 would be the closing php tag. Perhaps it has a problem with the semi-colon in line 11, that is right above?

    I also forgot to mention, i did not convert the SimplePie files into EE php templates or anything..I have left them in their directory on the root and refernce them via their web path. (ie http://www.url.com/inc/feed.php etc)I wasnt sure if EE would understand what all the crazy junk SimplePie was doing. I did change all template files that were using php in them to accept php though as well, incase that matters.

  • #4 / Jun 21, 2007 2:43pm

    Derek Jones

    7561 posts

    Well, line numbers won’t exactly match up by your tags—they will be in the position on your template at the time of parsing.

    Where is $feed defined?  That would appear to be the problem.

  • #5 / Jun 21, 2007 2:49pm

    mpace

    20 posts

    Well, line numbers won’t exactly match up by your tags—they will be in the position on your template at the time of parsing.

    Where is $feed defined?  That would appear to be the problem.

    $feed (singular) is defined in the template page where I want to spit out the results. (this i choose the name of and it can be anything)

    edit: ok, well i looked at the simplepie.inc page and it has $feed everywhere as well.. 5449 lines of code on that page (Sorry, I’m not sure if that is where its defined or not, most of this stuff is forign to me)

    $feeds (plural, an array) is defined in a simple php page in which I include in the template page

    <?php
        require_once('http://www.site.com/inc/feed.php');
    ?>

    feed.php includes the simplepie.inc file which is in the same directory as the feed.php page.

  • #6 / Jun 21, 2007 2:55pm

    Derek Jones

    7561 posts

    Gotcha.  Please see the Knowledge Base article: My PHP functions cannot reference global PHP variables.  Should fix things up.

  • #7 / Jun 21, 2007 3:05pm

    mpace

    20 posts

    Hmm.. i copied and pasted that example of code (correct implementation) into a php enabled template and I get the same sort of error.

    All I have in the page is..

    <?php
    
    global $foo;
    $foo = 'Hello World!';
    
    bar();
    
    function bar() {
      global $foo;
      echo $foo;
    ?>

    Parse error: syntax error, unexpected $end in /home/usr/public_html/site/dir/core/core.functions.php(629) : eval()‘d code on line 11

  • #8 / Jun 21, 2007 3:09pm

    Derek Jones

    7561 posts

    Double check your cut and paste. You are missing a closing ‘}’ on your bar() function. (the KB entry was missing the closing ?> tag which I have fixed, but the closing ‘}’ was there)

  • #9 / Jun 21, 2007 3:11pm

    mpace

    20 posts

    Ah ha, of course I am.

    Allright, now to try and figure out how to incorporate this into my feed spitter. I may be back!

    Thanks

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases