Created
August 15, 2025 16:34
-
-
Save thinkphp/48091e14ceb4c317c8cdf9905c70903d to your computer and use it in GitHub Desktop.
create database rogers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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