title: CodeIgniter - Database Error while connecting from Localhost
body: <p>I'm fairly new to development and I'm completely new to codeigniter.</p>
  
  <p>I've downloaded a CodeIgniter project from my company's server that I inherited from a previous developer.</p>
  
  <p>I need to add a new page to the site. Since I'm new to CI, I (obviously) don't want to edit the live site but I can't get the site to run locally. I'm trying to run it on a local server either through MAMP or through the PHP server in terminal on a Mac running Yosemite 10.10.5.</p>
  
  <p>I've added the project folder to htdocs in MAMP but when I open <a href="http://localhost:8888/index.php/contact" rel="nofollow noreferrer">http://localhost:8888/index.php/contact</a> the screen is blank. When I try to access the same folder through the terminal using:</p>
  
  <pre><code>env DB_USER=XXXX DB_PASSWD=XXXX DB_NAME=XXXX php -S localhost:8080
  </code></pre>
  
  <p>(where 'XXXX' is replaced with our database username and password) </p>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>Unable to connect to your database server using the provided settings.</p>
    
    <p>Filename: core/Loader.php</p>
    
    <p>Line Number: 346</p>
  </blockquote>
  
  <p>Line 346 of <code>core/Loader.php</code> is the <code>public function database</code> in the attached image.</p>
  
  <p><strong>Things I've tried:</strong></p>
  
  <blockquote>
    <p>• I've tried changing the <code>$config['base_url']</code> to  <code>'http://localhost:8888/';</code> but I still get the same error</p>
    
    <p>• Deleting the hostname, username and password from the <code>database.php</code> file, still get the same error</p>
  </blockquote>
  
  <p>I'm not sure why a local version can't access a database when the live site can with the same login credentials? Any help is much appreciated as I just started this new position, this is one of my first projects for the company and it has me stumped. I still need to figure out how to add a page, but I can't even get the site loaded locally so I can work on it.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here's what my <code>database.php</code> file looks like.....it's not setup as an array:</p>
  
  <p><code>/* The $active_group variable lets you choose which connection group to
  make active. By default there is only one group (the 'default' group).
  The $active_record variables lets you determine whether or not to load
  the active record class */</code></p>
  
  <pre><code>$active_group = 'default';
  $active_record = TRUE;
  
  $db['default']['hostname'] = 'localhost';
  $db['default']['username'] = 'root';
  $db['default']['password'] = '';
  $db['default']['database'] = 'database_name'; // contains actual name
  $db['default']['dbdriver'] = 'mysqli';
  $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;
  </code></pre>
  
  <p>** <strong>Link to video of me (trying to) explain this issue:</strong> **</p>
  
  <p>Link #1: <a href="https://youtu.be/5p43JyROUOs" rel="nofollow noreferrer">CodeIgniter Database Error Issue YouTube</a></p>
  
  <p>Thanks for your help!</p>
  
  <p><a href="https://i.stack.imgur.com/lxSBP.png" rel="nofollow noreferrer">core/loader.php</a></p>