Problem with News Section Tutorial |
[eluser]duartix[/eluser]
(EDIT) Solved. Cheers. I'm totally new to both PHP and CI and while trying to get past the News Section Tutorial, in the last line where it tells me to load the News view (in my case: http://localhost/testeCIstatic/index.php/news), I'm getting an unexpected error: ( ! ) Fatal error: Call to a member function row_array() on a non-object in C:\xampp\htdocs\testeCIstatic\application\models\news_model.php on line 16 This is my model: Code: <?php There is one strange issue in that the error reporting says it borks on line 16 but while debugging with Netbeans and Xdebug, I see that it happens well before that, as it gets inside the IF statement and it crashes in the Code: return $query->result_array(); $query is boolean and holds 0, so I'm guessing I've never managed to travel to the database. ![]() So, I've decided to debug: Code: public function __construct() { and into Loader.php/public function database Code: public function database($params = '', $return = FALSE, $active_record = NULL) $CI gets properly set, the if(class_exists ... statement doesn't return FALSE, the require_once doesn't change $return from FALSE, so the next if statement doesn't process, CI->db seems to read my configuration properly from application/config/database.php which looks like this: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Yet $query seemed empty, so can anyone please give a lead on this? Thanks in advance... Duarte Bruno
[eluser]duartix[/eluser]
Well, this is embarasing, a coworker just stepped in looked at my database configuration file and immediately spotted the problem: Code: $db['default']['database'] = "database_name"; It needed to be set. In my case the database was named data. All is well that ends well. But now, I'm questioning myself on where should lie the code for this kind of error trapping... |
Welcome Guest, Not a member yet? Register Sign In |