title: Connect sqlsrv in Xampp
body: <p>I have installed Xampp with a CodeIgniter installation. I want to connect from CodeIgniter to a SQL database.</p>
  
  <p>I changed the database config file and set the dbdriver to sqlsrv. </p>
  
  <pre><code>$active_group = 'default';
  $active_record = TRUE;
  
  $db['default']['hostname'] = 'IP Adress;
  $db['default']['username'] = 'DBUserName';
  $db['default']['password'] = 'DBPassword';
  $db['default']['database'] = 'DBName';
  $db['default']['dbdriver'] = 'sqlsrv';
  $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>In my controller I have the following code to try the connection:</p>
  
  <pre><code>$this-&gt;load-&gt;database();
  
  $db_obj = $this-&gt;db-&gt;load('sql_Test',TRUE);
  $connected = $db_obj-&gt;initialize();
  
  if (!$connected){
      $db_obj = $this-&gt;d-&gt;load('yyy',TRUE);
  } 
  else{
      die('connected');
  }
  </code></pre>
  
  <p>I have the following error:</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined function sqlsrv_connect() in
    C:\xampp\htdocs\system\database\drivers\sqlsrv\sqlsrv_driver.php on
    line 76</p>
  </blockquote>
  
  <p>I have read on a forum that I have to change line 89 from sqlsrv_driver.php:</p>
  
  <pre><code>function db_pconnect()
  {
      // $this-&gt;db_connect(TRUE); original
      return $this-&gt;db_connect(TRUE);
  }
  </code></pre>
  
  <p>What do I wrong?</p>