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

Cannot use object of type stdClass as array

 
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
sunzi
Smarty n00b


Joined: 09 May 2006
Posts: 3

PostPosted: Wed May 10, 2006 7:20 am    Post subject: Cannot use object of type stdClass as array Reply with quote

Hello There,

sorry, but I´m a newbie with smarty.
I get this erroe message:
Cannot use object of type stdClass as array
the php-script
-->
if($count == 1)
{
$invs = $db->get_results("select * from inventory");
$smarty->assign('inventory', $invs);
$smarty->display('inv.tpl');
}
else
{

<--

the template
{foreach item=inven from=$inventory}
{$inven.id} {$inven.vorname} {$inven.name} {$inven.team} {$inven.role} {$inven.computerType} {$inven.model} {$inven.hardwareDetails} {$inven.serviceTag} {$inven.deliveryDate} {$inven.screen} {$inven.licenseSoftware}<br>
{/foreach}

The array is filled fine, I print_r in php, but when I use the template i get
the error message.

Please help.

Thanks

Sun
Back to top
View user's profile Send private message
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Wed May 10, 2006 11:09 am    Post subject: Reply with quote

You have to use the variable syntax for object properties in your template:

http://smarty.php.net/manual/en/language.syntax.variables.php

Or you have to change your DB object to return arrays not objects for result sets.
________
vaporizer pipe
Back to top
View user's profile Send private message
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