How to fix this error message?
Can you help?
Fatal error: Cannot use object of type stdClass as array in C:\Program Files\EasyPHP-Devserver-16.1\eds-www\companygiondaci\application\views\pcategories.php on line 56
Fatal error: Cannot use object of type stdClass as array in C:\Program Files\EasyPHP-Devserver-16.1\eds-www\companygiondaci\application\views\pcategories.php on line 56
A PHP Error was encountered Severity: Error Message: Cannot use object of type stdClass as array Filename: views/pcategories.php
views/pcategories.php
<div class="row-fluid">
<div class="span12">
<button type="button" class="add" onclick="location.href='<?php echo site_url('cpages/addparentctg'); ?>';">ADD PARENT CATEGORIES</button>
<div class="widget-box">
<div class="widget-title"><h5>Parent Categories</h5></div>
<div class="widget-content">
<table border="0" style="width: 100%; height: 90px;">
<tr>
<td>PARENT NAME</td>
<td>DESCRIPTION</td>
<td>EDIT</td>
<td>DELETE</td>
</td>
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['ctgparent_name']; ?></td>
<td><?php echo $post['ctgparent_description']; ?></td>
<td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg/'.$post->ctgp_no); ?>';">EDIT</button></td>
<td><button type="button" class="delete" onclick="location.href='<?php echo site_url('cpages/editparentctg/'.$post->ctgp_no); ?>';">DELETE</button></td>
</td>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
controllers/Cpages.php
public function pcategories() {
$data['posts'] = $this->Mpages->call_parentctg();
//$data['ctgparent_name'] = $this->Mpages->call_parentctg();
//$data['ctgparent_description'] = "Second";//$this->Mpages->retrieve_parentctg();
$this->load->view('pcategories', $data);
}
models/Mpages.php
<!-- begin snippet: js hide: false console: true babel: false -->