title: Why the following error is coming in smarty foreach loop?
body: <p>Following is my code of foreach loop in smarty template:</p>
  <pre><code>{if $question_detail.question_has_sub_ques=='yes' &amp;&amp; $question_detail.sub_question}
        {foreach from=$question_detail.sub_question item=sub_ques_ans key=sub_ques_no}
        &lt;tr class=&quot;oddRow&quot;&gt;
          &lt;td class=&quot;question&quot;&gt;
            &lt;h4&gt;&lt;strong&gt;Sub-question {$page_question_no+1}.{$sub_ques_no+1}&lt;/strong&gt;&lt;/h4&gt;
            &lt;ul class=&quot;options&quot;&gt;
              &lt;li&gt;&lt;span&gt;{$sub_ques_ans.question_text}&lt;/span&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/td&gt;
          &lt;td class=&quot;question-id&quot;&gt;QUE{$sub_ques_ans.question_id}&lt;/td&gt;
        &lt;/tr&gt;
          {if $sub_ques_ans.question_file!=''}
        &lt;tr&gt;
          &lt;td valign=&quot;top&quot; colspan=&quot;2&quot;&gt;
            &lt;img src=&quot;{$ques_thum_image_path}{$sub_ques_ans.question_id}_{$sub_ques_ans.question_file}&quot;&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
          {/if}
          {if $question_detail.sub_question_answer_{$page_question_no+1}}
        &lt;tr class=&quot;question_answer evenRow&quot;&gt;
          &lt;td class=&quot;question&quot;&gt;
            &lt;p class=&quot;answers&quot;&gt;&lt;strong&gt;Answers&lt;/strong&gt;&lt;/p&gt; 
            &lt;ol class=&quot;options&quot;&gt;
            **{foreach from=$question_detail.sub_question_answer_{$page_question_no+1} item=sub_ans key=sub_ans_no}**
              &lt;li&gt;
              {if $sub_ans.answer_is_right==1} {assign var='correct_sub_ans' value=$sub_ans_no+1} {/if}
              {if $sub_ans.answer_text!=''}{$sub_ans.answer_text}{/if}&lt;br /&gt;
              {if $sub_ans.answer_file!=''}&lt;img src=&quot;{$ans_thumb_img_path}{$sub_ans.answer_id}_{$sub_ans.answer_file}&quot; &gt;{/if}
              &lt;/li&gt;  
            {/foreach}
            &lt;/ol&gt;
            &lt;p class=&quot;correct-answer&quot;&gt;&lt;strong&gt;Correct Answer Option : &lt;/strong&gt;{$correct_sub_ans}&lt;/p&gt;
          &lt;/td&gt;
          &lt;td class=&quot;question-id&quot;&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
          {/if}  
        {/foreach}
      {/if}
  </code></pre>
  <p>I'm getting error as follows:</p>
  <blockquote>
  <p>Fatal error: Smarty error: [in question-details.tpl line 66]:</p>
  <p>syntax error: foreach: missing 'item' attribute (SmartyCompiler.php, line 1179) in /var/www/eprime/ocn/core/libs/Smarty.php on line 1095</p>
  </blockquote>
  <p>And the line no.66 in my code is:</p>
  <pre><code>{foreach from=$question_detail.sub_question_answer_{$page_question_no+1} item=sub_ans key=sub_ans_no}
  </code></pre>
  <p>Can anyone help me in correcting this error? Any kind of help would be highly appreciated.</p>