|
Posted by Jochem Maas on 10/01/89 11:22
Matthew Weier O'Phinney wrote:
> * Patrick Roane <fojomo@sbcglobal.net>:
>
>>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.
Now I happen to know that you (Matthew Weier O'Phinney) are a 'heavy' user
of some/one of the PEAR DB classes because I read the php generals list
alot... I'm guessing your comments below are aimed at functionality
found in PEAR (which DB related class I have no idea) but it's only implied
- might I suggest that, given the fact Patrick calls himself a 'newbie',
that you make it a little more explicit so that he knows what you mean when
you start talking about stuff like DB_FETCHMODE_OBJECT. it would be ashame
if your insight was lost on him because he didn't grok the 'context'.
>
> 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!
>
Navigation:
[Reply to this message]
|