title: Why is my PHP not connecting to my MySQL database?
body: <p>I'm trying to connect to a database. If my php fails to connect to that database then it's programmed to create that database. I'm at a little bit of a dilemma, though; because I'm receiving this error: "Error creating database: Can't create database 'my_db'; database exists" So the database is there, but it appears that my php is unable to connect to it.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
      $db = "my_db";
      //establish a connection with the server
      $connection = mysqli_connect('localhost', 'root', '205360hello');
      if(!$connection){
          exit("&lt;p&gt;Could not establish a connection :" . mysqli_connect_error() . "&lt;/p&gt;");
      }
      //connect to the database
      $dbSelect = mysqli_select_db($db);
      if(!$dbSelect){
          // Create database
          $sql="CREATE DATABASE " . $db;
          if (mysqli_query($connection, $sql)) {
          } else {
            echo "&lt;p&gt;Error creating database: " . mysqli_error($connection) . "&lt;/p&gt;";
          }
      }
  ?&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>