title: xampp error: does not connect to database server , with codeigniter
body: <p>I am working on a codeigniter project. I developed it using wampserver locally, but I'd like to make some changes with xampp . It works fine on the remote site. Unfortunately when I try to run it locally I am getting:</p>
  
  <pre><code>A Database Error Occurred
  Unable to connect to your database server using the provided settings.
  Filename: F:\xampp-portable\htdocs\....\database\DB_driver.php
  Line Number: 124
  </code></pre>
  
  <p>to my index.php file , I have added:</p>
  
  <pre><code>mysql_connect("localhost","root","") or die ("Could not connect to mysql server.");
  mysql_select_db("contacts_db") or die ("Could not connect to database.");
  </code></pre>
  
  <p>This does NOT generate an error. Can anyone give me some pointers on what to check next?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Bill</p>
  
  <p>OK guys, here is the code around line 124:</p>
  
  <pre><code>function initialize()
  {
      // If an existing connection resource is available
      // there is no need to connect and select the database
      if (is_resource($this-&gt;conn_id) OR is_object($this-&gt;conn_id))
      {
          return TRUE;
      }
  
      // ----------------------------------------------------------------
  
      // Connect to the database and set the connection ID
      $this-&gt;conn_id = ($this-&gt;pconnect == FALSE) ? $this-&gt;db_connect() : $this-        &gt;db_pconnect();
  
      // No connection resource?  Throw an error
      if ( ! $this-&gt;conn_id)
      {
          log_message('error', 'Unable to connect to the database'); // 124
  
          if ($this-&gt;db_debug)
          {
              $this-&gt;display_error('db_unable_to_connect');
          }
          return FALSE;
      }
  </code></pre>
  
  <p>John was right, although I am now confused. I had set up the following code in my index.php to auto switch between xampp and server database config files:</p>
  
  <pre><code>define('ENVIRONMENT', isset($_SERVER['SERVER_NAME'])=='my_domain_name.com' ? 'production' : 'development');
  
      echo 'SERVER_NAME  '.$_SERVER['SERVER_NAME']; // getting localhost
      echo 'env '.ENVIRONMENT; // getting production.
  </code></pre>
  
  <p>I thought this would result in  the ENVIRONMENT constant set to 'development' with $_SERVER['SERVER_NAME']=localhost. Would someone mind explaining what I'm doing wrong here?</p>