title: MySQLI 28000/1045 Access denied for user 'root'@'localhost'
body: <p>I am having some trouble. So I am trying to connect to my database using MySQLi, but I am getting this error: </p>
  
  <pre><code>Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /home/venge/public_html/library/classes/database.class.php on line 16
  
  Warning: Missing argument 1 for Users::__construct(), called in /home/venge/public_html/routing.php on line 4 and defined in /home/venge/public_html/library/classes/users.class.php on line 3
  
  Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /home/venge/public_html/library/classes/database.class.php on line 16
  
  Warning: Cannot modify header information - headers already sent by (output started at /home/venge/public_html/library/classes/database.class.php:16) in /home/venge/public_html/routing.php on line 11
  </code></pre>
  
  <p>. I have no idea why it says "root" as the user, my code is below. I can login to PHPMyAdmin with that info fine.</p>
  
  <pre><code>&lt;?php
  
  $db['host'] = 'localhost';
  $db['user'] = 'venge_main';
  $db['pass'] = 'fakepassword';
  $db['name'] = 'venge_panel';
  
  
  class DB {
      function __construct($db) {
          $this-&gt;mysqli = new mysqli($db['host'], $db['user'], $db['pass'], $db['name']);
      }
      function query($i) {
          return $this-&gt;mysqli-&gt;query($i);
      }
      function fetch_array($i) {
          return $i-&gt;fetch_array(MYSQLI_ASSOC);
      }
      function num($i) {
          return $i-&gt;num_rows;
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Here is my global.php file:</p>
  
  <pre><code>&lt;?php
  session_start();
  
  $venge['library'] = 'library/classes/';
  
  include_once($venge['library'] . 'users.class.php');
  include_once($venge['library'] . 'database.class.php');
  $users = new Users($database);
  ?&gt;
  </code></pre>
  
  <p>Here is my users class: </p>
  
  <pre><code>&lt;?php
  class Users {
      public function __construct($db) {
          $this-&gt;db = new DB($db);
      }
      public function uidset() {
          if (isset($_SESSION['uid'])) {
              return true;
          } else {
              return false;
          }
      }
      public function securitycheck() {
          if (isset($_SESSION['uid'])) {
              //passed
              return true;
          } else {
              //failed
              die('No permissions');
          }
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Here is routing.php:</p>
  
  <pre><code>&lt;?php
  class Routing {
      public function __construct($route) {
          $this-&gt;users = new Users();
          $this-&gt;route = $route;
      }
      public function File() {
          if (!$this-&gt;users-&gt;uidset()) {
              switch ($this-&gt;route) {
                  default:
                      header("Location: /user/login");
                      break;
                  case '/user/login':
                      include_once('library/pages/login.page.php');
                      break;
              }
          } else {
              switch ($this-&gt;route) {
                  default:
                      header("Location: /venge");
                      break;
                  case '/venge':
                      echo 'Welcome to &lt;strong&gt;Venge&lt;/strong&gt; .';
                      break;
              }
          }
      }
  }
  
  $route = new Routing($_SERVER['ORIG_PATH_INFO']);
  
  $route-&gt;File();
  ?&gt;
  </code></pre>