[SMARTY] Re: newbie
Matthew Weier O'Phinney <[email protected]>
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
* Patrick Roane <[email protected]>: > I'm on ch 7 of the php5/myswl/ecomm book. > > > There is an error I get whenever I press the 'Edit > Categories' button: > > Fatal error: Cannot use object of type DB_result as > array in > c:\customfurniture\templates_c\%%F9^F97^F97AE06E%%admin_categories.tpl.php > on line 49 Sounds to me like you're either (1) trying to access an object using array-style syntax in Smarty, or (2) you're passing the wrong item to the template. In the case of (1), you probably retrieved the results of a DB call as an object (perhaps by setting DB_FETCHMODE_OBJECT), and passed the object to the template. Then you used syntax like: {$result.name} to print out the 'name' field of the result. However, that syntax is for accessing elements in an array; the correct syntax would be: {$result->name} which would access the name property of the object. In the case of (2), you may have performed a query that returned a resultset, but you didn't pull a record or set of records from the resultset to pass to the template. For example: $results = $db->query($sql); $tpl->assign('result', $results); when you should have done something like: $results = $db->query($sql); $row = $results->fetchRow(DB_FETCHMODE_ASSOC); $tpl->assign('result', $row); Good luck! -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php