title: Database Selection Failed. Unknown Database error on phpmyAdmin
body: <p>I am having trouble with selecting my database via PHP script on localhost.</p>
  
  <p>I am 100% sure that db name is spelled correctly and infact it appears on phpmyAdmin very well and only when I am trying to connect to it by running a PHP script on localhost it displays the following error:</p>
  
  <pre><code>Database selection failed Unknown database 'fokrul_justdeals'
  </code></pre>
  
  <p>My PHP code is here:</p>
  
  <pre><code>&lt;?php
      class database{
          public $connection;
          // the user for the database
          public $user = 'root';  
          // the pass for the user
          public $pswd = '';
          // the db from where you want to parse the info  
          public $db = 'fokrul_justdeals';
          // the host where db is located
          public $host = 'localhost';
  
          function __construct(){
              $this-&gt;connect();
          } 
  
          private function connect(){
              $this-&gt;connection = mysql_connect("$host", "$user", "$pswd") or die("Database connection failed ". mysql_error());
              if($this-&gt;connection){
                  // we select the db that we want to work with
                  mysql_select_db($this-&gt;db, $this-&gt;connection) or die("Database selection failed " . mysql_error());
              }
          }
  </code></pre>
  
  <p>I have read thousands of forums and I am doing everything as I shall be. But don't know what is going wrong here?</p>
  
  <p>One interesting thing is that out of all databases only system generated db 'mysql' connects if I change the db name to 'mysql' in PHP script.</p>
  
  <p>I have tried creating different db names and also tried creating new users and adding full privileges to them. Nothing has worked for me :(</p>