When creating a database in MySQL with PHP using the following code where does we make the connection and where does we make the database?
<p>I am new in PHP and would need some explanation. Here is a code where we connect to MySQL with PHP. Can you please explain me where is the statement that makes the connection? I can see only that we define what the value of $conn is, but does it mean execution as well? The other thing is: where do we create the database? I can see that we give the string "CREATE DATABASE myDB" as a value to $sql and we have an if statement, but does the expression ($conn->query($sql) === TRUE) also evaluated? It is strange for me, can somebody please explain it to me?! :) Thanks!</p>

<pre><code>&lt;?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
} 

// Create database
$sql = "CREATE DATABASE myDB";
if ($conn-&gt;query($sql) === TRUE) {
    echo "Database created successfully";
} else {
    echo "Error creating database: " . $conn-&gt;error;
}

$conn-&gt;close();
?&gt;
</code></pre>