Welcome Guest, Not a member yet? Register   Sign In
single view image


I'm trying to view a row with information in it. For example I have a list of titles and if I click the view link it has to give me all the information of that title.

I have managed to do half of it, I get the title and the content but not the image.
The error that I get is

Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: bras/bra_view.php

Line Number: 7

http://localhost/CodeIgniter_2.1.2/uploads/" />
and I get a broken picture

This is my controller
class Admin extends CI_Controller
public function __construct()

function bras() {

  $data['title'] = "Voluptuous Decadents";
  $data['heading'] = "Bras";
  $data['query'] = $this->db->get('bras');
  $this->load->view('admin/bras/bras', $data);

function bra_view($bra_id)
  $data['bra_item'] = $this->admin_model->get_bras($bra_id);

if (empty($data['bra_item']))

$data['title'] = $data['bra_item']['title'];

//$this->load->view('templates/header', $data);
$this->load->view('admin/bras/bra_view', $data);

and this is my model
class Admin_model extends CI_Model

public function get_bras($bra_id = FALSE)
if ($bra_id === FALSE)
  $query = $this->db->get('bras');
  return $query->result_array();

$query = $this->db->get_where('bras', array('bra_id' => $bra_id));
return $query->row_array();

this is my bras view
Bras view

<title><?php echo $title; ?></title>
<h1>&lt;?php //echo $heading ?&gt;</h1>
&lt;?php echo anchor('admin/bra_create', 'Create'); ?&gt;<br />

&lt;?php foreach($query->result() as $row): ?&gt;

&lt;?php echo $row->title ?&gt;<br />

&lt;?php echo anchor("admin/bra_view/$row->bra_id", 'view');?&gt;

&lt;?php echo anchor("admin/update_bras/$row->bra_id", 'Update');?&gt;
&lt;?php echo anchor("admin/delete_bras/$row->bra_id", 'Delete');?&gt;<br />

&lt;?php endforeach; ?&gt;


and this is my bra_view
This is the bras view

echo '<h2>'.$bra_item['title'].'</h2>';
echo $bra_item['content'];
<img src="&lt;?php echo base_url().'uploads/'.$bra_item-&gt;filename; ?&gt;" /><br />

You might want to check to see if $query is false or not, as it seems your query is failing for some reason.

I solved it. I had to change

<img src="&lt;?php echo base_url().'uploads/'.$bra_item-&gt;filename; ?&gt;" /><br />

<img src="&lt;?php echo base_url().'uploads/'.$bra_item['filename']; ?&gt;" /><br />

Theme © iAndrew 2016 - Forum software by © MyBB