can't connect to DB codeIgniter

Keeper01

I'm trying to learn CodeIgniter by myself. but when I followed the specific instruction from this tutorial http://www.codeigniter.com/user_guide/tutorial/news_section.html

this is my DB config

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'test',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => TRUE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

I get the following error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$db

Filename: pages/about.php

Line Number: 9

Backtrace:

File: /Applications/MAMP/htdocs/CodeIgniter/application/views/pages/about.php
Line: 9
Function: _error_handler

File: /Applications/MAMP/htdocs/CodeIgniter/application/controllers/Pages.php
Line: 18
Function: view

File: /Applications/MAMP/htdocs/CodeIgniter/index.php
Line: 292
Function: require_once


Fatal error: Call to a member function query() on null in /Applications/MAMP/htdocs/CodeIgniter/application/views/pages/about.php on line 9
A PHP Error was encountered

Severity: Error

Message: Call to a member function query() on null

Filename: pages/about.php

Line Number: 9

Backtrace:
Mr. ED

I am thinking it is because you did not autoload the database library.

Path: application/config/autoload.php

$autoload['libraries'] = array('database');

As why Message: Undefined property: CI_Loader::$db shown.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

can't connect to DB codeIgniter

From Dev

Laravel can't connect to DB

From Dev

node server can't connect to postgres db

From Dev

Can't connect to DB in virtual machine

From Dev

Laravel Homestead can't connect to db

From Dev

Wordpress php sqlite can't connect to .db

From Dev

SQLite can't connect to DB from Jar

From Dev

Can't connect to DB in virtual machine

From Dev

I can't connect to db or pull data

From Dev

can't connect to db in my sql

From Dev

Wordpress php sqlite can't connect to .db

From Dev

Can't connect to db - PlayFramework + Ebean

From Dev

Can't connect python with titan db

From Dev

Codeigniter connect to second DB based on first DB

From Dev

Using Docker to launch web app, can't connect to Postgresql DB?

From Dev

Maria DB Can't drop table with ENGINE=CONNECT without root

From Dev

Using Docker to launch web app, can't connect to Postgresql DB?

From Dev

Elixir/Phoenix can't connect to cloud hosted Postgres DB

From Dev

My Django App can't connect to DB through a TypeError

From Dev

EntityFramework.IBM.DB2 can't connect to db2

From Dev

JDBC Can't connect to my DB from a separate class. Class DB creates the connection

From Dev

Laravel Check if can connect to DB

From Dev

db doesn't connect or update

From Dev

SQL Server 2014- can't connect to local db - can not find server

From Dev

Can't connect to local SQL Server DB with connection string, but VS can

From Dev

Can't connect to EntityFramework

From Dev

Can't connect to Neo

From Dev

Can't connect to pgpool

From Dev

Can't Connect to Mlab