Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created August 15, 2025 16:34
Show Gist options
  • Save thinkphp/48091e14ceb4c317c8cdf9905c70903d to your computer and use it in GitHub Desktop.
Save thinkphp/48091e14ceb4c317c8cdf9905c70903d to your computer and use it in GitHub Desktop.
create database rogers
<?php
$host = "localhost";
$username = "adistatescu"
$password = "Adidas88statescu";
$database_name = "gallery_database";
try {
$mysqli = new mysqli($host, $username, $password);
if ($mysqli->connect_error) {
die('Connection failed: ' . $mysqli->connect_error);
}
$sql = "CREATE DATABASE IF NOT EXISTS `$database_name`";
if ($mysqli->query($sql) === TRUE) {
echo "Database '$database_name' created successfully!";
} else {
echo "Error creating database: " . $mysqli->error;
}
$mysqli->close();
} catch(Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment