title: cannot connect to cpanel database
body: <p>I have made an sql database in cpanel and adding some data to a table. I am now trying to access it and print out the data on my website, but I am not convinced I have the php correct. A tutorial I found to explain it is using xampp and not a real online website. so far I have a database handler php file with, </p>
  
  <pre><code>&lt;?php
  
  $dbServername = "localhost";
  $dbUsername = "username";
  $dbPassword = "password";
  $dbName = "databasename";
  
  $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
  </code></pre>
  
  <p>In my index.php file I have,</p>
  
  <pre><code>&lt;?php
  
  include_once('php/db_handler.php');
  
  ?&gt;
  
  //some html code
  
      &lt;?php
      //Choose all fields in table
      $sql ="SELECT * users;";
  
      //var to put in all the results
      $results = mysqli_query($conn, $sql);
  
      //var to get the number of rows returned.
      $resultcheck = mysqli_num_rows($result);
  
      //if the number of rows returned is not empty, then cycle through all results and print the stated ones to the screen.
      if($resultcheck &gt; 0){
          while($row = mysqli_fetch_assoc($result)) {
              echo $row['$email, $username'];
          }
      }
      ?&gt;
  
  
  
  
    //more html code
  </code></pre>
  
  <p>I am not totally sure what I should be using for database server name, In cpanel there is a section with server info and it gives me the servername webhosting2004, I have tried this also which does not work.</p>
  
  <p>The username and password are as per the user details in mysql databases (using my cpanel accountname_name)</p>
  
  <p>I get the following on the error log</p>
  
  <pre><code>[05-Nov-2019 12:31:51 UTC] PHP Warning:  mysqli_connect(): (HY000/1045): Access denied for user 'dannyjeb_admin'@'old' (using password: YES) in /home/dannyjeb/public_html/php/db_handler.php on line 8
  [05-Nov-2019 12:31:51 UTC] PHP Warning:  mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/dannyjeb/public_html/test.php on line 48
  [05-Nov-2019 12:31:51 UTC] PHP Warning:  mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/dannyjeb/public_html/test.php on line 51
  </code></pre>