|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
smartt Smarty Rookie
Joined: 24 Jul 2003 Posts: 10 Location: Dresden, Germany
|
Posted: Wed Aug 06, 2003 4:15 pm Post subject: foreach missing from attribute |
|
|
Hi,
i use an associative array (from a database) in a foreach loop. This works fine if this array isnīt empty (there are rows in the db table). if it is empty, i get the following error:
Fatal error: Smarty: [in admin_reisen_neu.tpl line 139]: syntax error: missing 'from' attribute (Smarty_Compiler.class.php, line 1002) in
what can i do. i tried already to use an {if $my_array neq "") around the foreach block, but this doesn`t work.
bye, Thomas
Last edited by smartt on Wed Aug 06, 2003 4:46 pm; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Aug 06, 2003 4:40 pm Post subject: |
|
|
what version of smarty are you using? |
|
Back to top |
|
smartt Smarty Rookie
Joined: 24 Jul 2003 Posts: 10 Location: Dresden, Germany
|
Posted: Wed Aug 06, 2003 4:45 pm Post subject: |
|
|
2.5.0 |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Aug 06, 2003 4:49 pm Post subject: |
|
|
hmm, how does line 139 (and maybe a few around that line) of admin_reisen_neu.tpl look ??? |
|
Back to top |
|
smartt Smarty Rookie
Joined: 24 Jul 2003 Posts: 10 Location: Dresden, Germany
|
Posted: Wed Aug 06, 2003 5:00 pm Post subject: |
|
|
it looks like this:
<tr>
<td>Kombireise-tag {$kombireisers}</td>
<td><select name="kombireise_id">
{foreach from=$kombireisers item=kombireise}
<option value="{$kombireise.id}">{$kombireise.titel}</option>
{foreach}
</select>
</td>
</tr>
i removed the if section, because it didnīt do anything
i assign $kombireisers(the associative array from db) as follows:
$smarty->assign("kombireisers", $kombireisers); |
|
Back to top |
|
smartt Smarty Rookie
Joined: 24 Jul 2003 Posts: 10 Location: Dresden, Germany
|
Posted: Wed Aug 06, 2003 5:04 pm Post subject: |
|
|
oooops, i just noticed that i forgot the slash at the end of the foreach. typo.
sorry |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Aug 06, 2003 5:10 pm Post subject: |
|
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|