Welcome Guest, Not a member yet? Register   Sign In
Problems with CI, please HELP
#1

[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>&lt;?=$heading?&gt;</h1>



&lt;?php foreach($query->result() as $row): ?&gt;

<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>

<p>&lt;?=ancor('blog/comments', 'Comments');?&gt;</p>

<hr />

&lt;?php endforeach; ?&gt;


&lt;/body&gt;

&lt;/html&gt;

------


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
#2

[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
#3

[eluser]andreagam[/eluser]
Quote:<p>&lt;?=ancor('blog/comments', 'Comments');?&gt;</p>

careful: 'anchor', not 'ancor'
#4

[eluser]cibill[/eluser]
i`ve done the changes but still nothing yet...
#5

[eluser]xwero[/eluser]
Have you set up your database config file?
#6

[eluser]cibill[/eluser]
this is my database.php config file:

&lt;?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'] = "";


?&gt;
#7

[eluser]xwero[/eluser]
that looks ok. Instead of autoloading the database try this
Code:
function index()
{
$data['title'] = "My Blog Title";
$data['heading'] = "My Blog Heading";
$this->load->database();
$data['query'] = $this->db->get('entries');

$this->load->view('blog_view', $data);
}
#8

[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
#9

[eluser]xwero[/eluser]
Happy birthday, but that is not a day for coding Smile

I find it strange that the autoloading doesn't work.
#10

[eluser]cibill[/eluser]
I know, but i`m playing not coding...Big Grin

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/)




Theme © iAndrew 2016 - Forum software by © MyBB