title: Accessing a MySQL database with php file
body: <p>I have a MySQL database and I am trying to figure out how to access it with a php file. I keep getting an error, so I was wondering if that was because my hostname is incorrect. If so, could anyone help me identify exactly what it is? The database is hosted on this website: <a href="https://christopherliao2002.000webhostapp.com/" rel="nofollow noreferrer">https://christopherliao2002.000webhostapp.com/</a>.</p>
  
  <p>Below is my HTML code. </p>
  
  <pre><code>    &lt;?php
      //Step1
      $db = mysqli_connect('localhost','***********','password','******')
      or die('Error connecting to MySQL server.');    
      ?&gt;
  
  &lt;html&gt;
   &lt;head&gt;
   &lt;/head&gt;
   &lt;body&gt;
   &lt;h1&gt;PHP connect to MySQL&lt;/h1&gt;
  &lt;?php
  //Variables
      $servername = "localhost";
      $username = "*****";
      $password = "****";
      $dbname = "******";
  
      //Connection to database
      $conn = new mysqli($servername, $username, $password, $dbname);
  
      //Test connection
  if ($conn-&gt;connect_error) {
  die("Connection failed: " . $conn-&gt;connect_error);
  }
  echo "Connected successfully";
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>