Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

foreach missing from attribute

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
smartt
Smarty Rookie


Joined: 24 Jul 2003
Posts: 10
Location: Dresden, Germany

PostPosted: Wed Aug 06, 2003 4:15 pm    Post subject: foreach missing from attribute Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Aug 06, 2003 4:40 pm    Post subject: Reply with quote

what version of smarty are you using?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
smartt
Smarty Rookie


Joined: 24 Jul 2003
Posts: 10
Location: Dresden, Germany

PostPosted: Wed Aug 06, 2003 4:45 pm    Post subject: Reply with quote

2.5.0
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Aug 06, 2003 4:49 pm    Post subject: Reply with quote

hmm, how does line 139 (and maybe a few around that line) of admin_reisen_neu.tpl look ???
Back to top
View user's profile Send private message Send e-mail Visit poster's website
smartt
Smarty Rookie


Joined: 24 Jul 2003
Posts: 10
Location: Dresden, Germany

PostPosted: Wed Aug 06, 2003 5:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
smartt
Smarty Rookie


Joined: 24 Jul 2003
Posts: 10
Location: Dresden, Germany

PostPosted: Wed Aug 06, 2003 5:04 pm    Post subject: Reply with quote

oooops, i just noticed that i forgot the slash at the end of the foreach. typo.

sorry
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Aug 06, 2003 5:10 pm    Post subject: Reply with quote

Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP