Welcome Guest, Not a member yet? Register   Sign In
function num_rows() Problem, well in localhost but not working on a web hosting
#1

[eluser]changereturnssuccess[/eluser]
hello all, I'm doing my first application with CodeIgniter. all is well in localhost but in the web hosting, the following code gives me this message

the code. is a view
Code:
<?php if($query->num_rows()>0): ?>
<?php foreach($query->result() as $row): ?>
<div class="img_thumb" style="float:left; width:150px; height:120px; margin:10px;"><img >thumb?&gt;" width="150" height="120" /></div>
<h2>&lt;?=$row->titulo?&gt;</h2>
<p>&lt;?=$ordena1 = nl2br($row->bajada); echo $ordena1;?&gt;</p><p>&lt;?=$ordena2 = nl2br($row->cuerpo); echo $ordena2;?&gt;</p>
<hr />

&lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;


the message.

Quote:Fatal error: Call to a member function num_rows() on a non-object in /home/pablo/public_html/codei/system/database/DB_active_rec.php on line 1080

something is wrong with web hosting?. in the localhost everything works well

any suggestions?
#2

[eluser]Maglok[/eluser]
It is suggesting that $query is not an object. Would need to see some controller/model for that. Mabye your config file on the webhost is not properly set up.

It doesnt seem to be a problem with your webhost per se, more with the setup you have on CI on it.

Have you changed your config.php variables to your webhosts? Like the domain and app/system dirs?
#3

[eluser]changereturnssuccess[/eluser]
thanks for answering,

the controller is this

Code:
class Noticias extends Controller{
function Noticias(){
parent::Controller();
$this->load->scaffolding('noticias');
}

function index()
{
$this->load->view('noticias/header');

$this->load->library('pagination');
$config['base_url'] = base_url()."index.php/noticias/index/";
$config['total_rows'] = $this->db->count_all_results('noticias');
$config['per_page'] = '3';    


$this->pagination->initialize($config);        

$variables['query'] = $this->db->get('noticias', $config['per_page'], (int)$this->uri->segment(3));
$this->load->view('noticias/index', $variables);

$this->load->view('noticias/pie');

}


I changed my config.php to function in the hosting, and also database.php, these two inside the config folder.


some syntax problem can exist in the code or hosting?

thanks




Theme © iAndrew 2016 - Forum software by © MyBB