title: No DB connection with MAMP and MSSQL (SQL Server), using CodeIgniter
body: <p>I'm running MAMP 3.0 on OS X and trying to connect to a remote SQL Server DB with no luck. I've followed what I could from other support questions regarding getting mssql enabled in my MAMP php install. Everything appears to be correct, mssqlsupport shows as enabled in phpinfo() </p>
  
  <p>The project is in CodeIgniter using the sqlsrv driver, and when running a db connection test I get nothing on screen and no errors in my MAMP logs or my CI logs. All debugging and error reporting appears to be turned on.</p>
  
  <p>I have just inherited this code base and am not very familiar with CI, but would appreciate any help on moving forward.</p>
  
  <p>UPDATED: I was able to get back data when querying without the CI DB class like so</p>
  
  <pre><code>$dbhandle = mssql_connect('host', 'user', 'password')
          or die("Couldn't connect to SQL Server.");
  
  $selected = mssql_select_db('mydb', $dbhandle) or die("Couldn't open database.");
  
  $query = "SELECT TOP 5 user_id, username FROM users";
  $result = mssql_query($query);
  </code></pre>
  
  <p>but not using </p>
  
  <pre><code>$this-&gt;load-&gt;database('production');
  print '&lt;b&gt;Database Version:&lt;/b&gt; ' . $this-&gt;db-&gt;version() . '&lt;br /&gt;';
  </code></pre>
  
  <p>and here is a dump of $this->load</p>
  
  <pre><code>object(CI_Loader)#13 (12) { ["_ci_ob_level"]=&gt; int(0) ["_ci_view_path"]=&gt; string(71) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/views/" ["_ci_library_paths"]=&gt; array(3) { [0]=&gt; string(77) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/third_party/" [1]=&gt; string(65) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/" [2]=&gt; string(60) "/Users/jojo/Websites/cms/inetpub/codeigniter/system/" } ["_ci_model_paths"]=&gt; array(2) { [0]=&gt; string(77) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/third_party/" [1]=&gt; string(65) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/" } ["_ci_helper_paths"]=&gt; array(3) { [0]=&gt; string(77) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/third_party/" [1]=&gt; string(65) "/Users/jojo/Websites/cms/inetpub/codeigniter/uploader/" [2]=&gt; string(60) "/Users/jojo/Websites/inetpub/codeigniter/system/" } ["_base_classes"]=&gt; array(12) { ["benchmark"]=&gt; string(9) "Benchmark" ["hooks"]=&gt; string(5) "Hooks" ["config"]=&gt; string(6) "Config" ["log"]=&gt; string(3) "Log" ["utf8"]=&gt; string(4) "Utf8" ["uri"]=&gt; string(3) "URI" ["router"]=&gt; string(6) "Router" ["output"]=&gt; string(6) "Output" ["security"]=&gt; string(8) "Security" ["input"]=&gt; string(5) "Input" ["lang"]=&gt; string(4) "Lang" ["loader"]=&gt; string(6) "Loader" } ["_ci_cached_vars"]=&gt; array(0) { } ["_ci_classes"]=&gt; array(0) { } ["_ci_loaded_files"]=&gt; array(0) { } ["_ci_models"]=&gt; array(1) { [0]=&gt; string(11) "httprequest" } ["_ci_helpers"]=&gt; array(0) { } ["_ci_varmap"]=&gt; array(2) { ["unit_test"]=&gt; string(4) "unit" ["user_agent"]=&gt; string(5) "agent" } }
  </code></pre>
  
  <p>When I investigated the sqlsrv_driver.php I can see that it is failing when trying to use @sqlsrv_connect but it is not returning any errors. It dies before continuing at all. I have tried exiting the script with errors after it attempts to create $res but nothing is returned. It is never getting beyond @sqlsrv_connect().</p>
  
  <pre><code>$res = @sqlsrv_connect($hostname, $connectionInfo);
  
      if(!$res){
          $this-&gt;_set_error(sqlsrv_errors());
      }
      return $res;
  </code></pre>
  
  <p>Here are my config/database settings:</p>
  
  <pre><code>$active_group = 'production';
  $active_record = TRUE;
  
  $db['production']['hostname'] = 'XXX';
  $db['production']['username'] = 'XXX';
  $db['production']['password'] = 'XXX';
  $db['production']['database'] = 'XXX';
  $db['production']['dbdriver'] = 'sqlsrv';
  $db['production']['dbprefix'] = '';
  $db['production']['pconnect'] = TRUE;
  $db['production']['db_debug'] = TRUE;
  $db['production']['cache_on'] = FALSE;
  $db['production']['cachedir'] = '';
  $db['production']['char_set'] = 'UTF-8';
  $db['production']['swap_pre'] = '';
  $db['production']['autoinit'] = TRUE;
  $db['production']['stricton'] = FALSE;
  </code></pre>
  
  <p>Worth noting, everything works fine on the actual production site, but it is a Windows machine running Apache (and PHP). There was also a custom sqlsrv driver written for CodeIgniter in the installation, to muddy things even more. Still, I believe the failure of @sqlsrv_connect($hostname, $connectionInfo) is the main problem, so far</p>