gongpex Posted September 24, 2014 Share Posted September 24, 2014 (edited) 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 September 24, 2014 by gong Link to comment Share on other sites More sharing options...
Ingolme Posted September 24, 2014 Share Posted September 24, 2014 Try using var_dump() on $product_list alone. Link to comment Share on other sites More sharing options...
gongpex Posted September 25, 2014 Author Share Posted September 25, 2014 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 More sharing options...
JamesB Posted September 25, 2014 Share Posted September 25, 2014 Are you sure you are connected to the database successfully? Also don't use var_dump like that, try having it on it's own line: var_dump($product_list); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now