Jump to content

codeignitier fatal error


gongpex

Recommended Posts

Hello everyone,

 

My site able to display well when I open it on localhost, but if I open it after I upload it on server it shown :

 

"Fatal error: Call to a member function row() on a non object in /srv/disk2/602761/www/ciportofolio.atwebpages.com/application/views/product.php on line 8"

 

this is my controller file :

<?php if(! defined('BASEPATH')) exit('no direct script access allowed');   class Product extends CI_Controller {        function __construct() {	 	   parent::__construct();	   $this->load->helper('url');	   $this->load->library('cart');	 	 }	 	 function index() {	 	   $this->load->library('template');	   $query =  $this->db->get('ci_item');	   $data['product_list'] = $query;	   $this->template->show('product',$data);	 }         }

and this is my views file (product.php):

<h1> PRODUCT PAGE </h1>      <h2><b>Product List</b></h2>    <?php    foreach($product_list->row() as $product) {	 echo "<li>".$product->id ." ";     echo $product->name ." ";     echo $product->price;		 echo " -- <a href=" /exp/index.php/cart/add/".$product->id."">Buy</a>";   }   ?>

Q : What mistake on my code?

 

note : I had try using var_dump on $product_list->row() but the result still same

 

please someone help me

 

Thanks

Edited by gong
Link to comment
Share on other sites

I had try using var_dump() like this :

<h1> PRODUCT PAGE </h1>      <h2><b>Product List</b></h2>    <?php    foreach(var_dump($product_list) as $product) {	 echo "<li>".$product->id ." ";     echo $product->name ." ";     echo $product->price;		 echo " -- <a href=" /exp/index.php/cart/add/".$product->id."">Buy</a>";   }   ?>

but it's result : Function name must be a string in /srv/disk2/602761/www/ciportofolio.atwebpages.com/application/views/product.php on line 8

 

Q : so, what I must do?

 

please help

 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...