Home › Forums › Programming › PHP & MySQL › CodeIgniter + Eclipse: function num_rows() on a non-object
Tagged: codeigniter, eclips, error, fatal error
- This topic has 1 reply, 1 voice, and was last updated 12 years, 4 months ago by Satish.
- AuthorPosts
- July 24, 2012 at 8:06 pm#1723SatishKeymaster
Error:
Fatal error: Call to a member function num_rows() on a non-object in C:\wamp\www\CI\application\models\site_model.php on line 8Solutions:
Make sure of these basic things:
in config -> database.php
Make sure all the values are correct: I know you’ve entered it correct, but still carefully check it once again :-)
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = ''; // usually it'll not be set, so leave as it is and check once
$db['default']['database'] = 'test'; // Common error. You have table by name test and you enter temp here :-)
$db['default']['db_debug'] = FALSE; // yes set it to FALSENow, config -> autoload.php
$autoload['libraries'] = array('database');
$autoload['helper'] = array('url');
Fatal error: Call to a member function num_rows() on a non-object in C:\wamp\www\CI\application\models\site_model.php on line 8
This error is commonly caused due to database errors..usually not able to connect to database! So check it carefully.July 24, 2012 at 8:29 pm#1727SatishKeymasterThis error also occurs when there is no data returned from the table.. i.e., when there is no data inside the table to return!
So first insert something into the database, specify proper field names while retrieving the data. - AuthorPosts
- You must be logged in to reply to this topic.