Skip to content

Instantly share code, notes, and snippets.

@dorp007
Created April 29, 2023 18:45
Show Gist options
  • Save dorp007/7db6e8dad170e66f97dd078e02d97252 to your computer and use it in GitHub Desktop.
Save dorp007/7db6e8dad170e66f97dd078e02d97252 to your computer and use it in GitHub Desktop.
<?php
$servername = "localhost";
$username = "yourusername";
$password = "yourpassword";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create database
$sql = "CREATE DATABASE myDB";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment