1

Actually I'm trying to configure my codeigniter live file to localhost.

I have,

  1. created a database called test_bs
  2. then imported the tables
  3. Then change the base_url like $config['base_url']=http://localhost/gu_ci/'; and $config['index_page']='index.php'; in config.php
  4. And then did a change on database.php,Which contains

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

My .htacess file having:

  RewriteEngine On
  RewriteBase /new_admin/

  RewriteCond %{REQUEST_URI} PIE.htc
  AddType text/x-component .htc
  RewriteRule (.*) static/PIE.htc [L]

  RewriteCond %{REQUEST_URI} !^/new_admin/static/

  RewriteRule (.*)$ index.php [L]

I'm getting the following error:

     A Database Error Occurred

     Unable to connect to your database server using the provided settings.

     Filename: C:\xampp\htdocs\gunify_ci\system\database\DB_driver.php

     Line Number: 124

I have referred Refer1, Refer2,Refer3,Refer4,Refer5 and so on... The last link just display the welcome message like: enter image description here But none of the solution helped me!!

Guide me to solve this!!

Community
  • 1
  • 1
PHP Learner
  • 111
  • 2
  • 4
  • 15
  • What do you use, WAMP Server? – Bora Jun 23 '15 at 08:51
  • Is there a space `$db['default']['password'] = ' ';` ? – AnkiiG Jun 23 '15 at 08:51
  • yes ji....it has,but if i removed that space also no change – PHP Learner Jun 23 '15 at 08:52
  • your database credentials seem to be wrong. Check the password that you have given is correct or not. – Harigovind R Jun 23 '15 at 08:52
  • @HarigovindR actually where we can check our password? Because i have use a password field as empty for all other projects in php – PHP Learner Jun 23 '15 at 08:54
  • So did you get any error lines? – Bora Jun 23 '15 at 08:54
  • No after setting db_debug to false, i don't get any error,but if set it to true i'm getting ` A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: C:\xampp\htdocs\gunify_ci\system\database\DB_driver.php Line Number: 124` – PHP Learner Jun 23 '15 at 08:57
  • @keerthi try removing the space between the quotes. Put quotes without space in between. If that dosent work we can add a new user in you database with a new password using the phpmyadmin. – Harigovind R Jun 23 '15 at 08:58
  • Hmm.. Can you try to set `pconnect` to `FALSE`? Sometimes it works ;) – Bora Jun 23 '15 at 09:00
  • @HarigovindR i have removed the space yar....but nothing happened – PHP Learner Jun 23 '15 at 09:01
  • @Bora i tried it earlier it would not help me – PHP Learner Jun 23 '15 at 09:03
  • When you debug, what you get? Like your REFER4. – Bora Jun 23 '15 at 09:04
  • actually if i do run using `http://localhost/pjct_folder/name/` it simply displays 404 error, if i run using `http://localhost/gunify_ci/index.php/home`, then it displays welcome page. my default controller is `$route['default_controller'] = "Home";` – PHP Learner Jun 23 '15 at 09:05
  • @keerthi Iam posting a link of a similer stack overflow question try the answer with 71 upvotes and try to figure out what are the errors. [Database connection failed with provided details](http://stackoverflow.com/questions/7254049/codeigniter-unable-to-connect-to-your-database-server-using-the-provided-settin) – Harigovind R Jun 23 '15 at 09:13
  • @HarigovindR ok ji...will check – PHP Learner Jun 23 '15 at 09:23
  • When i run the code `Connected OK` is displaying – PHP Learner Jun 23 '15 at 09:25
  • now your database connection is working fine. Remove those test statements and name your default controller correctly – Harigovind R Jun 23 '15 at 09:33

1 Answers1

4

$db['default']['password'] = ''; there is an space, remove it

use below settings

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'test_bs';
$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;

Edit 01

Use this .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

Edit 02

your folder structurer should be

  1. Application
  2. assets
    • css
      1. boostrap.css
      2. style.css
    • js
    • images
  3. system
  4. .htacess
  5. index.php

so code will be:

<link href="<?php echo base_url(); ?>assets/css/bootstrap.css" rel="stylesheet" />
potashin
  • 44,205
  • 11
  • 83
  • 107
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/81286/discussion-on-answer-by-abdulla-unable-to-connect-to-your-database-server-using). – Martijn Pieters Jun 23 '15 at 12:58