We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29319
    • 37 Posts
    This is the error I get
    PHP error debug
      Error: 	Invalid argument supplied for foreach()	 
      Error type/ Nr.: 	Warning - 2	 
      File: 	C:\xampp\htdocs\game\manager\includes\document.parser.class.inc.php(770) : eval()'d code	 
      Line: 	18



    When i add this snippet

    <?php
    error_reporting(E_ALL);
    
    require_once("C:/xampp/htdocs/game/forums/SSI.php"); 
    $array = ssi_recentTopics( 3, null, 'array');
    foreach ($array as $post)
    {
          echo '
          <form action="', $boardurl, '/SSI.php?ssi_function=pollVote" method="post" accept-charset="', $context['character_set'], '">
             <input type="hidden" name="poll" value="', $return['id'], '" />
             <table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
                <tr>
                   <td><b>', $return['question'], '</b></td>
                </tr>
                <tr>
                   <td>', $return['allowed_warning'], '</td>
                </tr>';
          foreach ($return['options'] as $option)
             echo '
                <tr>
                   <td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
                </tr>';
          echo '
                <tr>
                   <td><input type="submit" value="', $txt['poll_vote'], '" /></td>
                </tr>
             </table>
             <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
          </form>';
    }
    ?>



    Line 18 is


    <td><input type="submit" value="', $txt['poll_vote'], '" /></td>




    I’ve been looking at it for 30 minutes or so not a real clue any ideas?
      • 3749
      • 24,544 Posts
      I’m confused by your loop:

      foreach ($aray as $post) {}

      You’re not using the $post variable at all that I can see, it will be null the second time through the loop, and it will be of a different type on each iteration.

      Another possibility is that $return is not an array or is empty. Presumably it’s set in SSI.php.

      It would also help if we could see the snippet call.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting