title: Could not connect to MySQL: Unknown database 'logindb'
body: <p><a href="https://i.stack.imgur.com/B4J2W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B4J2W.png" alt="enter image description here"></a>I am trying to connect to mysql database logindb using a separate <strong>mysqli_connect.php</strong> file. Here is my code:</p>
  
  <pre><code>&lt;?php
  // This creates a connection to the logindb database and to MySQL,
  // It also sets the encoding.
  // Set the access details as constants:
  DEFINE('DB_USER', 'loger');
  DEFINE('DB_PASSWORD', 'loger');
  DEFINE('DB_HOST', 'localhost');
  DEFINE('DB_NAME', 'logindb');
  
  // Make the connection:
  $dbcon = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or   die('Could not connect to MySQL: ' .
  mysqli_connect_error());
  
  // Set the encoding...
  mysqli_set_charset($dbcon, 'utf8');
  
  ?&gt;
  </code></pre>
  
  <p>I ma using XAAMP on Windows, but I get this error:</p>
  
  <blockquote>
    <p>Could not connect to MySQL: Unknown database 'logindb'</p>
  </blockquote>
  
  <p>Windows Firewall had blocked Apache HTTP and mysql in Inbound Rules, I allowed the connection but still same error.
  I am hell confused what is wrong?</p>
  
  <p><strong>edit</strong></p>
  
  <p>I think the problem is with Firewall as maybe sql is blocked!
  Anyway I uninstalled the XAMPP and reinstalled it and made logindb again and added the user with all the privileges and now it works. Thank You!</p>