Skip to content

Instantly share code, notes, and snippets.

@nhandl3
Created October 9, 2013 08:21
Show Gist options
  • Save nhandl3/6897986 to your computer and use it in GitHub Desktop.
Save nhandl3/6897986 to your computer and use it in GitHub Desktop.
<?php
define('DB_NAME' , 'dbname' );
define('DB_USER' , 'user' );
define('DB_PASSWORD', 'pwd' );
define('DB_HOST' , 'localhost');
$con=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Create database
$sql="CREATE DATABASE ".DB_NAME;
if (mysqli_query($con,$sql))
{
echo "Database my_db created successfully";
}
else
{
echo "Error creating database: " . mysqli_error($con);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment