Problems with CI, please HELP |
[eluser]cibill[/eluser]
well this are my files and change i`ve been made: --- autoload.php for recognition of my database i`ve done this change | */ $autoload['core'] = array('database'); ------ My blog controller blog.php looks like this: <?php class Blog extends Controller { function Blog() { parent::Controller(); $this->load->helper('url'); $this->load->helper('form'); } function index() { $data['title'] = "My Blog Title"; $data['heading'] = "My Blog Heading"; $data['query'] = $this->db->get('entries'); $this->load->view('blog_view', $data); } } ?> ----- And my blog_view.php file looks like this: <html> <head> <title><?=$title?></title> </head> <body> <h1><?=$heading?></h1> <?php foreach($query->result() as $row): ?> <h3><?=$row->title?></h3> <p><?=$row->body?></p> <p><?=ancor('blog/comments', 'Comments');?></p> <hr /> <?php endforeach; ?> </body> </html> ------ well and the browser is showing me this Error Mesage: A PHP Error was encountered Severity: Notice Message: Undefined property: Blog::$db Filename: controllers/blog.php Line Number: 18 ------ QUESTION: where is the problem (i know line 18 blog.php), i did exactly the same thing like in video tutorial, maybe i`ve done wrong the cofig files, or what?! can anyone help me I have problems also with the links when i`m using the scaffolding, but this is another story... best regards
[eluser]xwero[/eluser]
[quote author="cibill" date="1193327160"]well this are my files and change i`ve been made: --- autoload.php for recognition of my database i`ve done this change | */ $autoload['core'] = array('database'); [/quote] you have to load the database class under the libraries key
[eluser]andreagam[/eluser]
Quote:<p><?=ancor('blog/comments', 'Comments');?></p> careful: 'anchor', not 'ancor'
[eluser]cibill[/eluser]
this is my database.php config file: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------- | DATABASE CONNECTIVITY SETTINGS | ------------------------------------------------------------------- | This file will contain the settings needed to access your database. | | For complete instructions please consult the "Database Connection" | page of the User Guide. | | ------------------------------------------------------------------- | EXPLANATION OF VARIABLES | ------------------------------------------------------------------- | | ['hostname'] The hostname of your database server. | ['username'] The username used to connect to the database | ['password'] The password used to connect to the database | ['database'] The name of the database you want to connect to | ['dbdriver'] The database type. ie: mysql. Currently supported: mysql, mysqli, postgre, odbc, mssql | ['dbprefix'] You can add an optional prefix, which will be added | to the table name when using the Active Record class | ['pconnect'] TRUE/FALSE - Whether to use a persistent connection | ['db_debug'] TRUE/FALSE - Whether database errors should be displayed. | ['active_r'] TRUE/FALSE - Whether to load the active record class | ['cache_on'] TRUE/FALSE - Enables/disables query caching | ['cachedir'] The path to the folder where cache files should be stored | | The $active_group variable lets you choose which connection group to | make active. By default there is only one group (the "default" group). | */ $active_group = "default"; $db['default']['hostname'] = "localhost"; $db['default']['username'] = "root"; $db['default']['password'] = "triadpass"; $db['default']['database'] = "code"; $db['default']['dbdriver'] = "mysql"; $db['default']['dbprefix'] = ""; $db['default']['active_r'] = TRUE; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; ?>
[eluser]xwero[/eluser]
that looks ok. Instead of autoloading the database try this Code: function index()
[eluser]cibill[/eluser]
thank you very very very much...XWERO if you lived in romania i would take you out for a drink (today is my birthday), thanks for listening best regards
[eluser]xwero[/eluser]
Happy birthday, but that is not a day for coding I find it strange that the autoloading doesn't work.
[eluser]cibill[/eluser]
I know, but i`m playing not coding... i`m using a triadserver... witch include php5 and apache, mysql server could be my localhost server the problem i use apache2triad http://apache2triad.net/ Also another problem i have is when i use scaffolding it`s open the first page... but for "add" or "view" i have this kind of link: localhost/code/scaffolding/add/localhost/code/... and is repeating over again (my root is localhost/code/) |
Welcome Guest, Not a member yet? Register Sign In |