Welcome Guest, Not a member yet? Register   Sign In
[ASK] Couldn;t connect to database
#1

[eluser]Unknown[/eluser]
Hi All, I wanna ask why I couldn't connect to database.

I am using CI version 2.1.2


this is my autoload.php :

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

this is my database.php :

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'db_mahasiswa';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

this is my config.php :

$config['base_url'] = 'http://localhost/ci';

In my controller, I have tes.php :

<?php

class tes extends CI_Controller {

function __construct()
{
parent::__construct();
}

function index()
{
$conn = $this->load->database();
if($conn)
echo 'success';
else
echo 'failed';
}
}

Is there any mistake in my configuration or code?...Thanks in advance.Smile)



Messages In This Thread
[ASK] Couldn;t connect to database - by El Forum - 07-03-2012, 11:07 PM
[ASK] Couldn;t connect to database - by El Forum - 07-04-2012, 04:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB