Bram Wijaya
Bram Wijaya

Reputation: 1

Uninitialized string offset: 0

I got this error when I load database:

A PHP Error was encountered Severity: Notice Message: Uninitialized string offset: 0 Filename: mysqli/mysqli_driver.php Line Number: 120 Backtrace: File: /home1/learnio3/public_html/application/controllers/Reading.php Line: 9 Function: database

File: /home1/learnio3/public_html/index.php
Line: 315
Function: require_once
public function __construct() {
    parent::__construct();
    $this->load->database();
    $this->load->helper('url');

}

database.php

$active_group = 'default';
$query_builder = TRUE;

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

Upvotes: 0

Views: 3246

Answers (1)

Swarnadeep Bagchi
Swarnadeep Bagchi

Reputation: 51

change hostname => '' to hostname => 'localhost' , dont keep it blank , Even if it is a webserver , cloud9 etc , pass 'localhost' although in phpmyadmin host name is "%"

Upvotes: 5

Related Questions