title: Cannot select database
body: <p>I'm trying to display a <code>SQL</code> database using <code>php</code>.</p>
  
  <p>I get an error: </p>
  
  <pre><code>Cannot Select Database (running local on XAMPP).
  </code></pre>
  
  <p>In <code>XAMPP</code> I went into <code>xampp-security</code> and changed the password of the superuser to "thisthing"</p>
  
  <p>I have a file named: <code>mydb.sql</code></p>
  
  <p>mydb.sql:</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE `dpuForm` ( 
  `ID` INT  NOT NULL  AUTO_INCREMENT ,
  `JN` TINYTEXT  NOT NULL ,
  `PN` TINYTEXT  NOT NULL ,
  `QTY` TINYTEXT  NOT NULL ,
  `DESC` TINYTEXT  NOT NULL ,
  PRIMARY KEY (`ID`) );
  
  INSERT INTO 'dpuForm' ('JN',...........yadayadayada
  </code></pre>
  
  <p>And here's my php:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  $host = "localhost";
  $username="root";
  $password="thisthing";
  $database="mydb";
  
  mysqli_connect($host,$username,$password);
  @mysqli_select_db($database) or die( "Unable to select database");
  
  $query = "SELECT * FROM dpuForm";
  $result = mysqli_query($query);
  $num = mysqli_numrows($result);
  
  mysqli_close();
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;table&gt;
      &lt;th&gt;Job Number&lt;/th&gt;
  &lt;th&gt;Part Number&lt;/th&gt;
  &lt;th&gt;QTY&lt;/th&gt;
  &lt;th&gt;Description&lt;/th&gt;
  
  &lt;?php
        $i=0;
        while ($i &lt; $num) {
    $f1=mysqli_result($result,$i,"JN");
    $f2=mysqli_result($result,$i,"PN");
    $f3=mysqli_result($result,$i,"QTY");
    $f4=mysqli_result($result,$i,"DESC");
      ?&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;?php echo $f1; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $f2; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $f3; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $f4; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
      &lt;?php $i++;} ?&gt;
   &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>