Welcome Guest, Not a member yet? Register   Sign In
Categories & Subcategories
#6

[eluser]Dyllon[/eluser]
[quote author="sunnyd" date="1257140223"]
In my view file, I have:

Code:
<h1>Categories</h1>
<p>&lt;?php echo anchor(base_url(). 'admin/shop/add-category', 'Add Category'); ?&gt;</p>
<p>&lt;?php echo $this->session->flashdata('message'); ?&gt;</p>
&lt;?php foreach ($categories as $cat) { ?&gt;
    <p>&lt;?php echo $cat->cat_name; ?&gt;</p>
&lt;?php } ?&gt;

When trying to list the categories, I get the following error:

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/categories.php

Line Number: 5

[/quote]

Line 5 in your view, $cat is an array not an object.

Code:
<h1>Categories</h1>
<p>&lt;?php echo anchor(base_url(). 'admin/shop/add-category', 'Add Category'); ?&gt;</p>
<p>&lt;?php echo $this->session->flashdata('message'); ?&gt;</p>
&lt;?php foreach ($categories as $cat) { ?&gt;
    <p>&lt;?php echo $cat['cat_name']; ?&gt;</p>
&lt;?php } ?&gt;


Messages In This Thread
Categories & Subcategories - by El Forum - 11-01-2009, 04:25 PM
Categories & Subcategories - by El Forum - 11-01-2009, 04:39 PM
Categories & Subcategories - by El Forum - 11-01-2009, 04:46 PM
Categories & Subcategories - by El Forum - 11-01-2009, 04:55 PM
Categories & Subcategories - by El Forum - 11-01-2009, 05:37 PM
Categories & Subcategories - by El Forum - 11-01-2009, 08:59 PM
Categories & Subcategories - by El Forum - 11-02-2009, 10:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB