PHP – Create a Database in MySQL

The given PHP example helps you to create a database in MySQL.

Code Example:
$username = "root";
$password = "root";
$conn = mysql_connect($hostname,$username, $password) or die ("Unable to connect to database!");

if(mysql_query("CREATE DATABASE mydatabase",$conn)) 
  echo "Database created";
  echo "Error creating database: " . mysql_error();


Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *