title: How to fix the issue: "localhost is currently unable to handle this request. HTTP ERROR 500"
body: <p>I have a PHP script which connects to a database setup up with MAMP. </p>
  
  <p>However it doesn't seem to be able to connect to the database. Every time I tried, it has failed with the message: </p>
  
  <blockquote>
    <p>This page isn’t working localhost is currently unable to handle this
    request. HTTP ERROR 500</p>
  </blockquote>
  
  <pre><code>&lt;?php 
  
          $host = "localhost:8889";
          $dbusername = "root";
          $dbpassword = "root";
          $dbname = "HMSDb"; 
  
          //Create connection
          $conn = new mysqli_connect($host, $dbusername, $dbpassword, $dbname);
  
          $sql = "SELECT * FROM login;";
          $result = mysqli_query($conn, $sql);
          $resultCheck = mysqli_num_rows($result);
  
          if ($resultCheck &gt; 0) {
              while ($rows = mysqli_fetch_assoc($result)) {
                  echo $row['username'] . "&lt;br&gt;";
          } else {
                  echo "Fail";
          }
  
  ?&gt;
  </code></pre>