title: PHP (5.5.7) Warning connecting to MySQLi in Windows Servers 2008 R2
body: <p>I'm running Moodle on PHP 5.5.7 64bit nts on Windows Server 2008 R2 with MySQL 5.5.36. </p>
  
  <p>Up until two days ago, there were no problems. To deal with Xdebugger being such a memory hog, an extra CPU and more memory was assigned to the virtual machine. The Windows license was also activated. The entire vm was rebooted. (I had restarted the machine before prior to this, with no problems).</p>
  
  <p>I am now receiving the following warning when I access any page on the site:</p>
  
  <pre><code>    PHP Warning:  mysqli::mysqli(): (HY000/2002): A connection attempt failed because the  connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
      in C:\inetpub\wwwroot\moodle\lib\dml\mysqli_native_moodle_database.php on line 375
  </code></pre>
  
  <p>I created a test php page that simply consists of the following:</p>
  
  <pre><code>    $mysqli = new mysqli("127.0.0.1", "moodleuser", 'xxxx', "moodle", 3306);
      if ($result = $mysqli-&gt;query("SELECT * from mdl_user limit 10")) {
          echo "Select returned $result-&gt;num_rows";
      } else {
          echo "Error";
      }
      $mysqli-&gt;close();
  </code></pre>
  
  <p>I receive the following output:</p>
  
  <pre><code>    PHP Warning:  mysqli::mysqli(): (HY000/2002): A connection attempt failed because          the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.in C:\inetpub\wwwroot\moodle\info.php on line 17
      PHP Warning:  mysqli::query(): Couldn't fetch mysqli in C:\inetpub\wwwroot\moodle\info.php on line 18
      PHP Warning:  mysqli::close(): Couldn't fetch mysqli in C:\inetpub\wwwroot\moodle\info.php on line 24
  </code></pre>
  
  <p>I have checked that "127.0.0.1  localhost" exists in my hosts file and that the IPv6 "::1" line has been commented out. 
  I have also attempted to use "localhost" but same problem.</p>
  
  <p>The bizarre thing is that if I refresh the page, occasionally, and completely at random, the warning doesn't occur and the correct output is given.</p>
  
  <p>I have attempted to disable the warnings, but php appears to be ignoring me. Also, disabling the warning is not exactly ideal. </p>
  
  <p>Any ideas? </p>
  
  <p>EDIT:</p>
  
  <p>So after much pain staking back and forths between PHP and MySQL and IIS, it looks like (once again) it was php.ini to blame. </p>
  
  <p>To be honest, I cant even tell you which setting was the problem - but I changed all possible timeout related settings in php.ini to a large number (10000 or -1 depending on the setting), as well as the connection_timeout for mysql in my.ini.</p>
  
  <p>I am still yet to figure out which one was causing the problem, but will edit this post if I ever do. </p>